Friday, July 19, 2013

Java MCQ Test – 3

Que.1. Which of the following is synchronized?

A:    Set
B:    LinkedList
C:    Vector
D:    WeakHashMap

Right Answer: A

Que.2. What kind of thread is the Garbage collector thread is?

A:    Non daemon thread
B:    Daemon thread
C:    Thread with dead state
D:    None of the above

Right Answer: B

Que.3. Which of the following below is true for StringBuffer?

A:    Both B and C
B:    When an application is to run a single thread using some changes for strings, it is advisable to use StringBuffer
C:    StringBuffer class is not synchronized
D:    StringBuffer is thread safe

Right Answer: A

Que.4. When a thread terminates its processing, into what state that thread enters?

A:    Running state
B:    Waiting state
C:    Dead state
D:    Beginning state

Right Answer: C

Que.5. For an interface class, All methods in an interface must not have abstract access modifier

A:    True
B:    False

Right Answer: A

Que.6. Which of these statements is true?

A:    LinkedList extends List
B:    AbstractSet extends Set
C:    HashSet extends AbstractSet
D:    WeakHashMap extends HashMap

Right Answer: C

Que.7. Select all the true statements from the following.

A:    AbstractSet extends AbstractCollection
B:    AbstractList extends AbstractCollection
C:    HashSet extends AbstractSet
D:    Vector extends AbstractList
E:    All choices are correct.

Right Answer: E

Que.8. Which of the following statements is true?

A:    A subclass is a sub set of a superclass
B:    class ClassTwo extends ClassOne means ClassOne is a subclass
C:    class ClassTwo extends ClassOne means ClassTow is a super class
D:    the class Class is the super class of all other classes in Java.

Right Answer: A

Que.9. Which of the following statements is preferred to create a string "Welcome to Java Programming"?

A:    String str = "Welcome to Java Programming"
B:    String str = new String( "Welcome to Java Programming")
C:    String str; str = "Welcome to Java Programming"
D:    String str; str = new String ("Welcome to Java Programming")

Right Answer: A

Que.10. Which statement is true?

A:    HashTable is a sub class of Dictionary
B:    ArrayList is a sub class of Vector
C:    LinkedList is a subclass of ArrayList
D:    Vector is a subclass of Stack

Right Answer: A

Que.11. How many numeric data types are supported in Java?

A:    8
B:    4
C:    2
D:    6

Right Answer: D

Que.12. All the wrapper classes (Integer, Boolean, Float, Short, Long, Double and Character) in java __________.

A:    are private
B:    are serializable
C:    are immutatable
D:    are final

Right Answer: D

Que.13. The code snippet if ( "Welcome".trim() == "Welcome".trim() ) System.out.println("Equal"); else System.out.println("Not Equal");
will ___________.

A:    compile and display Equal
B:    compile and display Not Equal
C:    cause a compiler error
D:    compile and display NULL

Right Answer: C

Que.14. ____________ compiler coverts a byte code of one operating system to the current operating system's executable code

A:    JTI
B:    JJT
C:    JIT
D:    JVM

Right Answer: A

Que.15. A ResourceBundle is a group of related sub classes which are _____________

A:    having different base names
B:    sharing the same base name

Right Answer: A

Que.16. An interface contains ______________ methods

A:    Non-abstract
B:    Implemented
C:    unimplemented

Right Answer: C

Que.17. Which of the following statements declare class Sample to belong to the payroll.admindept package?

A:    package payroll;package admindept;
B:    import payroll.*;
C:    package payroll.admindept.Sample;
D:    import payroll.admindept.*;
E:    All choices are correct.

Right Answer: D

Que.18. The class java.lang.Exception is

A:    protected
B:    extends Throwable
C:    implements Throwable
D:    serializable

Right Answer: B

Que.19. Consider the following code snippet. What will be assigned to the variable fourthChar

String str = new String("Java");
char fourthChar = str.charAt(4);

A:    a
B:    v
C:    throws StringIndexOutofBoundsException
D:    null characater

Right Answer: C

Que.20. Which of the following statements is true?

A:    An exception can be thrown by throw keyword explicitly.
B:    An exception can be thrown by throws keyword explicitly.

Right Answer: A

No comments:

Post a Comment