Friday 30 October 2015

JAVA SOLVED MCQS FOR UGC NET COMPUTER SCIENCE



                       JAVA SOLVED MCQS FOR UGC NET COMPUTER SCIENCE

1.       What is the difference between a class and object
A.      A class represents a collection of objects
B.      A class defines the attributes and behavior of an object
C.      An object represents a collection of classes
D.      Both class and object are one and the same
Ans.: B

        2.     What happens if a class defines a method with the same name and parameters a method in its super class
A.      The compiler automatically renames the subclass method
B.      The program runs since because overriding methods is allowed
C.      The program throw a duplicate method exception
D.      The subclass methods will be ignored.              
Ans.: B
  
3. Which of the following are examples of polymorphism
A.      Method overriding
B.      Method overloading
C.      Accessors and mutators
D.      Both a and b
Ans.: D


4.   Which of the following is not a type of java program?
A.      Applet
B.      Servlet
C.      Pagelet
D.      Standalone application
Ans.: C

5.  Which one of the following is not correct about a java program.
A.      The execution of a java program starts with main() method
B.      The main() can take one or more arguments
C.      The main() method need not be placed inside a class
D.      The main() method should have the public access specifier
Ans.: C.

6.  Which of the following is not a token?
A.      Keyword
B.      Identifier
C.      Method
D.      Literal
Ans.: C

7. The class that handles data input from the console is
A.      InputStream
B.      System.in
C.      Both A and B
D.      None
Ans.: B

8. An inner class has free access to private member data of the outer classes.
            A.False
            B.True
            C.It depends upon situation
            D.None
Ans.: B

 9.  Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized.
A.      Java.util.HashSet
B.      Java.util.LinkedHashSet
C.      Java.util.List
D.      Java.util.ArrayList
Ans.: D

10.    Predict the output:
public class Question
{
public static void main(String ars[])
{
String s1=”abc”;
String s2=”def”;
String s3=s1.concat(s2.toUpperCase());
System.out.println(s1+s2+s3);
}
}
A.      Abcdefabcdef
B.      abcabcDEFDEF
C.      abcdefabcDEF
D.      None of the above
Ans.: C

11..   Which package is imported by default?
A.      Java.awt
B.      Java.lang
C.      Java.applet
D.      None of the above
Ans.: B

Click to buy Cosmo's UGC NET Computer Sceince Book
12.   You need to store elements in a collection that guarantees that no duplicates are stored. Which one of the following interfaces provide that capability.
A.      Java.util.Map
B.      Java.util.Set
C.      Java.util.List
D.      Java.util.collection
Ans.: B

13.   Which of the following is not correct.
A.      Every thread will go through the waiting state during its lifetime
B.      A thread will reach dead state when the execution of its run() is over
C.      Every thread will start its life with the new state
D.      When the run() of a thread is bein executed, it is said to be in running state.
Ans.: A

14.    Which of the following is wrong.
A.      Runnable interface is a predefined interface
B.      The sleep() instructs a thread to terminate its execution
C.      The isAlive() tells whether a thread has not yet died.
D.      MAX_PRIORITY represents the level 10.
Ans.: B

15.    Which of the following is wrong.
A.      FileWriter and FileReader classes deal with character data.
B.      A stream gets data from a source and sends data to a destination
C.      FileOutputStream class deals with binary data
D.      BufferedOutputStream and BufferedInputStream classes deal with character data
Ans.: D

16.   Which interface provides a way to access elements within the collection.
A.      Collections
B.      Runnable
C.      Iterator
D.      None of the above
Ans.: C

17.  Find the incorrect statement
A.  A dynamic array can grow and shrink
B.  Linked list class is available in java.lang package
C.   Algorithms constitute a part of collection framework
D.    Iterator is like an index
Ans.: B

18.  Find the odd man out:
A.      Runtime class
B.      StringBuffer class
C.      Random class
D.      Object class
Ans.: C.
Tip: All other classes belong to java.lang package.

19.    Which of the following is true
A.      An objet will be garbage collected when it becomes unreachable
B.      An object will be garbage collected if it has null assigned to it
C.      The finalize method will be run before an object is garbage collected
D.      Garbage collection assures that a program will never run out of memory.
Ans.: C

20.   Which of the following initializes Boolean primitive.
A.      Boolean flag=true.
B.      boolean flag=true;
C.      boolean flag=TRUE;
D.      Boolean flag=TRUE;
Ans.: b


No comments:

Post a Comment