Friday, May 17, 2013

Java MCQ Test – 1


Que.1. Which of the following statements is false about objects?
A.    An instance of a class  is an object
B.     Object can access both static and instance data.
C.    Object is the super class of all other classes
D.    Object do not permit encapsulation

Right Answer: D

Que.2. All the wrapper class (Integer, Boolean, Float, Short, Long, Double and Character) in java
A.    are private
B.     are serializable
C.    are immutable
D.    are finale

Right Answer: D

Que.3. The code snippet if (“Welcome”.trim() == ”Welcome”.trim()) System.out.println(“Equals”); 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.4. What is an aggregate?
A.    An object with only primitive attributes.
B.     An instance of a class which has only static methods.
C.    An instance which has other objects.
D.    None of the above.

Right Answer:  C

Que.5. A class can have many methods with the same name as long as the number of parameters or type of parameters is different. This OOP concept is known as ________.
A.    Method Invocating.
B.     Method Overriding.
C.    Method Labeling.
D.    Method Overloading.

Right Answer: D

Que.6. When a thread terminates its processing, into what state the thread enters?
A.    Running State.
B.     Waiting State.
C.    Dead State.
D.    Beginning State.

Right Answer: C

Que.7. Which methods can access to private attributes of a class?
A.    Only static methods of the same class.
B.     Only instance of the same class.
C.    Only methods those defined in the same class.
D.    Only classes available in the same package.

Right Answer: C

Que.8. Which of the following is considered as a blue print that defines the variables and methods common to all of its objects of a specific kind?
A.    Object
B.     Class
C.    Method
D.    Real data types

Right Answer: B

Que.9. Which of the following statement is true?
A.    A subclass is a sub set of a superclass.
B.     Class ClassTwo extends ClassOne means ClassOne is subclass.
C.    Class ClassTwo extends ClassOne means ClassTwo is super class.
D.    The class Class is the super class of all other classes in Java.

Right Answer: A

Que.10. What is the meaning of the return data type void?
A.    An empty memory space is returned so that developers can utilize it.
B.     Void returns no data type.
C.    Void is not supported in Java.
D.    None of the above.

Right Answer: B

Que.11. A lower precision can be assigned to higher precision value in Java. For exa. A byte type  data  can be assigned to int type.
A.    True
B.     False

Right Answer: A

Que.12. What is the data type for the number 9.6352?
A.    float.
B.     double.
C.    Float.
D.    Double.

Right Answer: B

Que.13. Which of the following is synchronized?
A.    Set.
B.     linkedList.
C.    Vector.
D.    WeakHashMap.

Right Answer: A

Que.14. To execute the thread one after another.
A.    the keyword synchronize is used.
B.     the keyword synchronizable is used.
C.    the keyword synchronized is used.
D.    None of the above.

Right Answer: B

Que.15. Which of the following statements are about the Java language is true?
A.    Both procedural and OOP are supported in Java.
B.     Java supports only procedural approach towards programming.
C.    Java supports only OOP approach.
D.    None of the above.

Right Answer: A

Que.16. If result = 2+3*5, what is the value and type of result variable?
A.    17, byte.
B.     25, byte.
C.    17, int.
D.    25, int.

Right Answers: C

Que.17. How many numeric data types are supported in Java?
A.    8
B.     4
C.    2
D.    6

Right Answers: D

Que.18. Which of the statement is reserved word in java?
A.    Run
B.     Import
C.    transient
D.    Implement

Right Answers: B

Que.19. Which of the following is not a return type?
A.    boolean
B.     void
C.    public
D.    Button

Right Answer: C

Que.20. Which of the following statement 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

6 comments:

  1. I think the answer for Quest 14 is C and not B
    keyword synchronized is used for the method.

    ReplyDelete
  2. yup the answer of 14 question is 'C'

    ReplyDelete
  3. Q18 => TRANSIENT IS A KEYWORD

    ReplyDelete
  4. 13 answer is c not a
    vector is synchronized by default on jdk1.0 itself

    ReplyDelete
  5. Thank you all of u....

    ReplyDelete