Study Viral (Java Tutorials For Beginners - Step By Step)
  • Home
  • Java Tutorials
    • Core Java
    • Java Swing
    • MS Access JDBC Java Application
  • Facebook Page
  • Programs
    • C Programs
    • C++ Programs
    • Java Programs
    • Python Programs
  • UGC NET
  • Home
  • Java Tutorials
    • Core Java
    • Java Swing
    • MS Access JDBC Java Application
  • Facebook
  • Programs
    • C Programs
    • C++ Programs
    • Java Programs
    • Python Programs
  • UGC NET

UGC NET JULY 2018 (Computer Science And Applications Paper-II) Question 5-6

 July 13, 2018     Computer Science And Applications Paper-II, UGC NET JULY 2018     No comments   

UGC NET JULY 2018 (Computer Science And Applications Paper-II) Question 5-6



Q5. Given below are three implementations of the swap() function in C++.


(a)(b)(c)
void swap (int a,int b)
{
       int temp;
       temp = a;
       a = b;
       b = temp;
}
int main()
{
       int p = 0, q =1;
       swap(p,q);
}
void swap (int &a,int &b)
{
       int temp;
       temp = a;
       a = b;
       b = temp;
}
int main()
{
       int p = 0, q =1;
       swap(p,q);
}
void swap (int *a,int *b)
{
       int *temp;
       temp = a;
       a = b;
       b = temp;
}
int main()
{
       int p = 0, q =1;
       swap(&p,&q);
}


Which of the following actually swap the contents of the two integer variables p and q ?  

(1). (a) only                    (2).  (b) only               (3).  (c) only                  (4). (b) and  (c) only

 Answer : (2). (b) only

Reason : If we execute option (a) code than that code will only pass the value of p and q to the function swap (i.e. called pass by value) which will not exchange the values of p and q also there is no use of address operator.

If we execute option (b) code than that code will pass address locations of p and q to swap function instead of actual values. Now the temp stores the value of a (i.e. address location of p, e.g. 1000) when temp = a; after that we have a=b; which replaces the value of a with new value of b i.e. address of q, e.g. 1002 and b=temp; again replaces the actual value of b with value temp (i.e. address location of p). When the swap function finishes its execution part with exchange the content of variable p and q because it replaces the address locations.

If we try to execute option (c) than the code will work fine but it will not replace the content of p and q. Here inside the swap function there is only exchange of addresses for pointer variable a and b not for p and q, So there is exchange of contents for p and q.


Q6. In Java which of the following statement is/are true ?

S1 : The 'final' keyword applied to a class definition prevents the class from being extended through derivation.

S2 : A class can only inherit one class but can implement multiple interfaces.

S3 : Java permits a class to replace the implementation of a method that it has inherited. It is called method overloading.

Code :
(1).  S1 and S2 only                                                (2).  S1 and S3 only
(3).  S2 and S3 only                                                (4).  All of S1,S2 and S3

Answer :  (1).  S1 and S2 only        

Reason : The statement S1 is true, we can not extends a class which having final keyword with class declaration.
The Second statement S2 is also true that Java don't allow us to extend multiple classes at one time but Java allows us to implement multiple interfaces by using implements keyword.

The third statement S3 is false because the ability of a subclass to override a method allows a class to inherit from a superclass and it is called overriding. The overriding method has the same name, number and type of parameters, and return type as the method that it overrides. An overriding method can also return a subtype of the type returned by the overridden method.
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook
Newer Post Older Post Home

0 comments:

Post a Comment

Facebook

StudyViral

Labels

Alphabet Pattern Binary Tree BLOB (Binary Large Object) Computer Networks Computer Science And Applications Paper-II Data Structure DBMS Digital Clock Digital Watch Extra Tutorials File Upload Find Age from Date of Birth Graph-Algorithms Java and J2EE web applications JAVA JDK 12 Java Mail API Java MySQL Java Programs Java Programs List Java Servlets Java Swing Java Swing With MySQL Database Java Tutorials JCalender KVS Compuer Science - January 2017 Question Paper MS Access JDBC Java Application Multiuser Login NETBEANS 11 IDE Occurrence of Digits in Number Operation System Pattern Program Reverse of String Sending Email Servlet Servlet Tutorial Software Engineering Star Struts 2 FrameWork Struts 2 Registration Form UGC NET JULY 2018 Windows Commands

Popular Posts

  • Program 01: Write a program to display/print your name.
     Program 01 - Write a program to display/print your name. This is a very basic and introductory program in Java. You might see similar p...
  • Install NetBeans 11 IDE on Windows 10 - Study Viral
    Install NetBeans 11 IDE on Windows 10 - Study Viral How to Install NetBeans 11 IDE on Windows 10. Download Link : https://netbeans...
  • Create CON, AUX, NUL name folder and files in Windows - Study Viral
    Create CON, AUX, NUL name folder and files in Windows - Study Viral Most of you may be aware of many MS-DOS commands but still n...

Categories

  • Alphabet Pattern (13)
  • Binary Tree (2)
  • BLOB (Binary Large Object) (1)
  • Computer Networks (2)
  • Computer Science And Applications Paper-II (40)
  • Data Structure (6)
  • DBMS (1)
  • Digital Clock (1)
  • Digital Watch (1)
  • Extra Tutorials (3)
  • File Upload (1)
  • Find Age from Date of Birth (1)
  • Graph-Algorithms (1)
  • Java and J2EE web applications (3)
  • JAVA JDK 12 (1)
  • Java Mail API (3)
  • Java MySQL (5)
  • Java Programs (44)
  • Java Programs List (3)
  • Java Servlets (3)
  • Java Swing (16)
  • Java Swing With MySQL Database (4)
  • Java Tutorials (37)
  • JCalender (1)
  • KVS Compuer Science - January 2017 Question Paper (6)
  • MS Access JDBC Java Application (6)
  • Multiuser Login (1)
  • NETBEANS 11 IDE (1)
  • Occurrence of Digits in Number (1)
  • Operation System (4)
  • Pattern Program (8)
  • Reverse of String (2)
  • Sending Email (1)
  • Servlet (3)
  • Servlet Tutorial (3)
  • Software Engineering (4)
  • Star (7)
  • Struts 2 FrameWork (2)
  • Struts 2 Registration Form (1)
  • UGC NET JULY 2018 (40)
  • Windows Commands (2)

Pages

  • Java Tutorials
  • ASP.NET (in Hindi)
  • Java Programs List

Blog Archive

  • ►  2021 (3)
    • ►  April 2021 (3)
  • ►  2019 (7)
    • ►  June 2019 (1)
    • ►  May 2019 (2)
    • ►  March 2019 (4)
  • ▼  2018 (111)
    • ►  November 2018 (7)
    • ►  October 2018 (20)
    • ►  September 2018 (10)
    • ►  August 2018 (3)
    • ▼  July 2018 (19)
      • Java Swing Retrieve Image From Database (MySQL) as...
      • Java Swing - Save Image to Database (MySQL) as BLO...
      • UGC NET JULY 2018 (Computer Science And Applicatio...
      • UGC NET JULY 2018 (Computer Science And Applicatio...
      • UGC NET JULY 2018 (Computer Science And Applicatio...
      • UGC NET JULY 2018 (Computer Science And Applicatio...
      • UGC NET JULY 2018 (Computer Science And Applicatio...
      • UGC NET JULY 2018 (Computer Science And Applicatio...
      • UGC NET JULY 2018 (Computer Science And Applicatio...
      • UGC NET JULY 2018 (Computer Science And Applicatio...
      • UGC NET JULY 2018 (Computer Science And Applicatio...
      • UGC NET JULY 2018 (Computer Science And Applicatio...
      • UGC NET JULY 2018 (Computer Science And Applicatio...
      • UGC NET JULY 2018 (Computer Science And Applicatio...
      • UGC NET JULY 2018 (Computer Science And Applicatio...
      • UGC NET JULY 2018 (Computer Science And Applicatio...
      • UGC NET JULY 2018 (Computer Science And Applicatio...
      • UGC NET JULY 2018 (Computer Science And Applicatio...
      • UGC NET JULY 2018 (Computer Science And Applicati...
    • ►  June 2018 (5)
    • ►  May 2018 (2)
    • ►  April 2018 (3)
    • ►  March 2018 (11)
    • ►  February 2018 (18)
    • ►  January 2018 (13)
  • ►  2017 (36)
    • ►  December 2017 (10)
    • ►  November 2017 (9)
    • ►  October 2017 (7)
    • ►  September 2017 (10)

About Me

Rohit Basra
Hello guys my name Rohit Basra. I love to code and teach java language.
View my complete profile

Followers

Copyright © Study Viral (Java Tutorials For Beginners - Step By Step) | Powered by Blogger