Monday, June 3, 2013

Java MCQ Test – 2

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

Right Answer: C

Que.2. 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 Answer: C

Que.3. The inner class can access private members of the outer class.
A.    False
B.    True

Right Answer: A

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

Right Answer: B

Que.5. Which of the following statements is true?
A.    The default char data type is a space (“ ”) character.
B.    The default integer data type is int and real data type is float.
C.    The default integer data type is long and real data type is float.
D.    The default integer data type is int and real data type is double.

Right Answer: D

Que.6. What is the meaning of the return data type void?
A.    An empty memory space is returned so that the 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.7. What are the interfaces defined by java.lang?
A.    Cloneble
B.    Comparable
C.    Runnable
D.    a,b and c

Right Answer: D

Que.8. Does Java support multiple inheritance?
A.    No
B.    Yes

Right Answer: A

Que.9. Assume that the value 3929.92 is of type float. How to assign this value after declaring the variable interest of type float?
A.    interest = 3929.92
B.    interest = (Float)3929.92
C.    interest = 3929.92(float)
D.    interest = 3929.92f

Right Answer: D

Que.10. ____________ allow primitive data types to be accessed as objects.
A.    Both B and D.
B.    Serialized class.
C.    Primitive class.
D.    Wrapper class.

Right Answer: A

Que.11. What is the value of number after the following code fragment execution?
int number  = 0; int number2 = 12; while (number < number2) { number = number + 1; }
A.    5
B.    12
C.    21
D.    13

Right Answer: B

Que.12. Java beans have no types.
A.    True
B.    False

Right Answer: C

Que.13. __________ are utilized to control the access to an object especially in multi threaded programming.
A.    Asynchronized methods.
B.    Serialized methods.
C.    Synchronized methods.
D.    Both A and C

Right Answer: A

Que.14. What are the two parts of a value of type double?
A.    Significant, Digits, Exponent
B.    Length, Denominator
C.    Mode, Numerator

Right Answer: A

Que.15. Given the following code snippet;
int salaries[]; int index = 0; salaries = new int salaries[4]; while (index < 4) { salaries[index] =  10000; index++; } What is the value of salaries[3]?
A.    40000
B.    50000
C.    15000
D.    10000

Right Answer: D

Que.16. Which of the following statements 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.17. A lower precision can be assigned to higher precision value in Java. For exa. A byte data can be assigned to int type.
A.    True.
B.    False.

Right Answer: A

Que.18.
public class returnData
{
[returnType] getData (byte a, double z)
{
return (short)a/z * 10;
}
}
What is valid reurnType for getData?
A.    Int
B.    Byte
C.    Short
D.    Double
Right Answer: D

Que.19. After the following code fragment, what is the value in fname?
String str; int fname; str = “Foolish boy.”; fname = str.indexOf(“fool”);
A.    0
B.    2
C.    -1
D.    4

Right Answer: C

Que.20. __________ can be used to control the order of certain data structure and collection of objects too.
A.    Serial Comparators.
B.    Natural Comparators.
C.    Comparators.
D.    All of above.

Right Answer: C


No comments:

Post a Comment