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?class N { int p; double q; } class M extends N { int r; } public class result { public static void main(String args[]) { N p = new N(); M q = new M(); Class object; object = q.getClass(); System.out.print(object.isInstance(p)); } } |
| 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?class N { int p; double q; } class M extends N { int r; } public class Result { public static void main(String args[]) { N p = new N(); M q = new M(); Class object; object = q.getClass(); System.out.print(q.equals(p)); } } |
| 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?class N { int p; double q; } class M extends N { int r; } public class Result { public static void main(String args[]) { N p = new N(); M q = new M(); Class object; object = q.getClass(); System.out.print(object.getSuperclass()); } } |
| 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?public class isNaN_Example { public static void main(String args[]) { Double num = new Double(1 / 0.); boolean p = num.isNaN(); System.out.print(p); } } |
| A. | true |
| B. | false |
| C. | 0 |
| D. | 1 |
| E. | None of these |
| Answer» C. 0 | |
| 5. |
What is the output of this program?public class isinfinite_Example { public static void main(String args[]) { Double num = new Double(1 / 0.); boolean p = num.isInfinite(); System.out.print(p); } } |
| 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?class N { int p; double q; } class M extends N { int r; } public class Result { public static void main(String args[]) { N p = new N(); M q = new M(); Class object; object = q.getClass(); System.out.print(object.isLocalClass()); } } |
| 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?class N { int p; double q; } class M extends N { int r; } public class Output { public static void main(String args[]) { N p = new N(); M q = new M(); Class object; object = p.getClass(); System.out.print(object.getName()); } } |
| A. | p |
| B. | q |
| C. | N |
| D. | M |
| E. | r |
| Answer» D. M | |
| 10. |
What is the output of this program?class N { int p; double q; } class M extends N { int r; } public class Result { public static void main(String args[]) { N p = new N(); M q = new M(); Class object; object = q.getClass(); System.out.print(object.getSuperclass()); } } |
| 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?double n = Math.round ( 4.5 + Math.random() ); |
| A. | 1 |
| B. | 2 |
| C. | 3 |
| D. | 4 |
| E. | 5 |
| Answer» F. | |
| 12. |
What is the output of this program?public class binary_Example { public static void main(String args[]) { int n = 16; System.out.print(Integer.toBinaryString(n)); } } |
| 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?public class Result { public static void main(String args[]) { Integer n = new Integer(260); byte p = n.byteValue(); System.out.print(p); } } |
| A. | 0 |
| B. | 1 |
| C. | 2 |
| D. | 3 |
| E. | 4 |
| Answer» F. | |
| 17. |
What is the output of this program?public class Result { public static void main(String args[]) { char array[] = {'P', '8', 'Q', ' '}; System.out.print(Character.isDigit(array[1]) + " "); System.out.print(Character.isWhitespace(array[2]) + " "); System.out.print(Character.isUpperCase(array[0])); } } |
| 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 | |