

MCQOPTIONS
Saved Bookmarks
This section includes 26 Mcqs, each offering curated multiple-choice questions to sharpen your Java Programming knowledge and support exam preparation. Choose a topic below to get started.
1. |
What is the output of this program?
|
A. | true true |
B. | false false |
C. | true |
D. | false |
E. | None of these |
Answer» E. None of these | |
2. |
What is the output of this program?
|
A. | false |
B. | true |
C. | true false |
D. | false true |
E. | None of these |
Answer» B. true | |
3. |
What is the output of this program?
|
A. | class M |
B. | M |
C. | class N |
D. | N |
E. | None of these |
Answer» D. N | |
4. |
What is the output of this program?
|
A. | true |
B. | false |
C. | 0 |
D. | 1 |
E. | None of these |
Answer» C. 0 | |
5. |
What is the output of this program?
|
A. | true true |
B. | false false |
C. | false |
D. | true |
E. | None of these |
Answer» E. None of these | |
6. |
What is the output of this program?
class box_Shape { int width; int height; int length; } public class mainclass { public static void main(String args[]) { box_Shape obj = new box_Shape(); System.out.println(obj); } } |
A. | Compiletime error |
B. | Runtime error |
C. | Garbage value |
D. | box_Shape@2a139a55 |
E. | None of these |
Answer» E. None of these | |
7. |
What is the output of this program?
class box_Shape { int width; int height; int length; } public class mainclass { public static void main(String args[]) { box_Shape obj1 = new box_Shape(); box_Shape obj2 = new box_Shape(); obj1.height = 3; obj1.length = 4; obj1.width = 6; obj2 = obj1; System.out.println(obj2.height); } } |
A. | 3 |
B. | 2 |
C. | 1 |
D. | Runtime error |
E. | Garbage value |
Answer» B. 2 | |
8. |
What is the output of this program?
|
A. | True |
B. | False |
C. | 0 |
D. | 1 |
E. | None of these |
Answer» E. None of these | |
9. |
What is the output of this program?
|
A. | p |
B. | q |
C. | N |
D. | M |
E. | r |
Answer» D. M | |
10. |
What is the output of this program?
|
A. | N |
B. | M |
C. | Class N |
D. | Class M |
E. | None of these |
Answer» D. Class M | |
11. |
What is the value of n after this line of code has been executed?
|
A. | 1 |
B. | 2 |
C. | 3 |
D. | 4 |
E. | 5 |
Answer» F. | |
12. |
What is the output of this program?
|
A. | 10000 |
B. | 00001 |
C. | 00100 |
D. | 01000 |
E. | 1000 |
Answer» B. 00001 | |
13. |
What is the output of this program?
class N { int K; int L; N() { K = 1; L = 2; } } public class Result { public static void main(String args[]) { N obj = new N(); System.out.print(obj.toString()); } } |
A. | false |
B. | Compilation Error |
C. | true |
D. | String associated with obj |
E. | None of these |
Answer» E. None of these | |
14. |
What is the stored in the object obj in following lines of code?
box obj; |
A. | Any arbitrary pointer |
B. | Memory address of allocated memory of object |
C. | Garbage |
D. | NULL |
E. | None of these |
Answer» E. None of these | |
15. |
What is the output of this program?
public class Result { public static void main(String args[]) { Object object = new Object(); System.out.print(object.getclass()); } } |
A. | Compilation error |
B. | class object |
C. | class java.lang.Object |
D. | Runtime error |
E. | None of these |
Answer» B. class object | |
16. |
What is the output of this program?
|
A. | 0 |
B. | 1 |
C. | 2 |
D. | 3 |
E. | 4 |
Answer» F. | |
17. |
What is the output of this program?
|
A. | true false true |
B. | false true true |
C. | true true true |
D. | false false false |
E. | false true false |
Answer» B. false true true | |
18. |
What is the output of this program?
public class Result { public static void main(String args[]) { Object o = new Object(); System.out.print(o.getClass()); } } |
A. | class java.lang.Object |
B. | Object |
C. | Compilation Error |
D. | class Object |
E. | None of these |
Answer» B. Object | |
19. |
What is the output of this program?
class N { int K; int L; N() { K = 1; L = 2; } } public class Result { public static void main(String args[]) { N object = new N(); System.out.print(object.toString()); } } |
A. | Compilation Error |
B. | true |
C. | false |
D. | String associated with object |
E. | None of these |
Answer» E. None of these | |
20. |
What is the output of this program?
class box_Shape { int width; int height; int length; } public class mainclass { public static void main(String args[]) { box_Shape obj = new box_Shape(); obj.width = 12; obj.height = 4; obj.length = 15; int p = obj.width * obj.height * obj.length; System.out.print(p); } } |
A. | 420 |
B. | 520 |
C. | 620 |
D. | 720 |
E. | 820 |
Answer» E. 820 | |
21. |
What is the output of this program?
public class main_class_Example { public static void main(String args[]) { int p = 10; if (p == 10) { // int p = 20; int q = 20; System.out.println(q); } } } |
A. | 10 |
B. | 20 |
C. | 11 |
D. | 21 |
E. | 25 |
Answer» C. 11 | |
22. |
Which of these class have only one field TYPE ? |
A. | System |
B. | Runtime |
C. | Process |
D. | Void |
E. | None of these |
Answer» E. None of these | |
23. |
What is the value of n after this line of code has been executed? |
A. | 1 |
B. | 2 |
C. | 3 |
D. | 4 |
E. | 5 |
Answer» F. | |
24. |
What is the value of double consonant E defined in Math class? |
A. | approximately 0 |
B. | approximately 2.72 |
C. | approximately 3.14 |
D. | approximately 3 |
E. | None of these |
Answer» C. approximately 3.14 | |
25. |
Standard output variable out is defined in which class? |
A. | Process |
B. | System |
C. | Void |
D. | Runtime |
E. | None of these |
Answer» C. Void | |
26. |
What is the stored in the object obj in following lines of code? |
A. | Any arbitrary pointer |
B. | Memory address of allocated memory of object |
C. | Garbage |
D. | NULL |
E. | None of these |
Answer» E. None of these | |