11 Sep 100 Java MCQ (Multiple Choice Questions) with Answers
Show Answer
2) Who developed the Java programming language?
Show Answer
3) Which component of Java is responsible for executing the bytecode?
Show Answer
4) What is the entry point method in a Java application?
Show Answer
5) Which keyword is used to inherit a class in Java?
Show Answer
6) What is the default value of a boolean variable in Java?
Show Answer
7) Which of these is a primitive data type in Java?
Show Answer
8) Which keyword is used to create an instance of a class?
Show Answer
9) What is the size of an int variable in Java?
Show Answer
10) Which keyword is used to make a variable’s value unchangeable?
Show Answer
11) Which method is used to find the length of a String in Java?
Show Answer
12) How do you declare an array in Java?
Show Answer
13) Which keyword is used to handle exceptions in Java?
Show Answer
14) What package is automatically imported into every Java program?
Show Answer
15) Which of the following is NOT a Java access modifier?
Show Answer
16) What is the default value of an object reference variable in Java?
Show Answer
17) Which keyword is used to access members of the parent class?
Show Answer
18) What exception is thrown when an array is accessed with an invalid index?
Show Answer
19) Which operator is used to compare two primitives for equality in Java?
Show Answer
20) What is the superclass of all classes in Java?
Show Answer
21) Which keyword is used to declare an interface in Java?
Show Answer
22) Can a class implement multiple interfaces in Java?
Show Answer
23) Which method in the Object class is used to check for structural equality?
Show Answer
24) Which loop is guaranteed to execute at least once?
Show Answer
25) What is the result of 10 / 4 using integer division in Java?
Show Answer
26) Which of the following classes is immutable in Java?
Show Answer
27) What keyword is used to define a constant method that cannot be overridden?
Show Answer
28) Which keyword is used to invoke a constructor of the current class?
Show Answer
29) What is the size of a char data type in Java?
Show Answer
30) Which memory area in JVM stores class structures like runtime constant pool, field, and method data?
Show Answer
31) Which exception occurs when dividing an integer by zero in Java?
Show Answer
32) What keyword is used to define a class that cannot be instantiated?
Show Answer
33) Which collection class allows duplicate elements in Java?
Show Answer
34) Which collection does NOT allow duplicate keys?
Show Answer
35) Which keyword is used to prevent serializing a field in Java?
Show Answer
36) Which thread method is used to start execution of a thread?
Show Answer
37) Which interface must be implemented to create a thread by passing it to the Thread class?
Show Answer
38) What is the default initial capacity of an ArrayList in Java?
Show Answer
39) What is the output of “Hello”.charAt(1)?
Show Answer
40) Which statement is used to exit from a loop prematurely?
Show Answer
41) Which statement skips the current iteration of a loop?
Show Answer
42) Which class is synchronized and thread-safe?
Show Answer
43) Which class is preferred for mutable strings in a non-multithreaded environment?
Show Answer
44) Which keyword is used to declare a variable that may be modified by different threads asynchronously?
Show Answer
45) Which block is guaranteed to execute regardless of whether an exception occurs or not?
Show Answer
46) What does garbage collection in Java do?
Show Answer
47) What method of Garbage Collector can be suggested to run manually?
Show Answer
48) What is method overriding?
Show Answer
49) What is method overloading?
Show Answer
50) Can static methods be overridden in Java?
Show Answer
51) What is the return type of a constructor in Java?
Show Answer
52) Which keyword is used to throw an explicit exception?
Show Answer
53) Which keyword is used in a method signature to declare exceptions that the method might throw?
Show Answer
54) What type of exception is NullPointerException?
Show Answer
55) Which exception is a Checked Exception in Java?
Show Answer
56) What does the static keyword mean when applied to a field?
Show Answer
57) Which wrapper class corresponds to the float primitive type?
Show Answer
58) What is autoboxing in Java?
Show Answer
59) What is unboxing in Java?
Show Answer
60) Which operator is used to instantiate an object or array?
Show Answer
61) What is the default value of a double variable in Java?
Show Answer
62) Which method converts a string representation of a number to an integer?
Show Answer
63) Which collection class maintains insertion order?
Show Answer
64) Which map class maintains keys in sorted order?
Show Answer
65) What is the scope of a private member of a class?
Show Answer
66) What is the default access modifier if none is specified?
Show Answer
67) Which feature was introduced in Java 8 to support functional programming?
Show Answer
68) What interface represents a function that takes one argument and produces a result in Java 8?
Show Answer
69) Which functional interface returns a boolean value given an argument?
Show Answer
70) Which functional interface takes no arguments and returns a result?
Show Answer
71) What does the Stream.filter() method do in Java Streams API?
Show Answer
72) Which of the following is a terminal operation in Java Streams?
Show Answer
73) What is the purpose of Optional class introduced in Java 8?
Show Answer
74) How can you define a default implementation for a method inside an interface (Java 8+)?
Show Answer
75) What is the size of byte primitive type in Java?
Show Answer
76) What is the range of a byte data type in Java?
Show Answer
77) What happens if you try to compile a Java class without a main method?
Show Answer
78) Which statement about static initializer blocks is true?
Show Answer
79) What is marker interface in Java?
Show Answer
80) Which of the following is a built-in marker interface in Java?
Show Answer
81) What is the default capacity multiplier of an ArrayList when it grows?
Show Answer
82) Which of the following allows null keys in Java?
Show Answer
83) What is the result of “Java”.concat(“SE”)?
Show Answer
84) What is the output of Math.abs(-5.5)?
Show Answer
85) Which class can be used to read input from the console easily?
Show Answer
86) Which keyword is used to access package members from another package?
Show Answer
87) Can an abstract class have constructors in Java?
Show Answer
88) Can an interface have instance fields in Java?
Show Answer
89) What is the difference between == and .equals() when comparing String objects?
Show Answer
90) What is String Pool in Java?
Show Answer
91) What method is used to manually add a String object to the String Pool?
Show Answer
92) What is the bitwise XOR operator in Java?
Show Answer
93) What is the output of 5 & 3 in Java?
Show Answer
94) Which right shift operator preserves the sign bit (arithmetic shift)?
Show Answer
95) What is the unsigned right shift operator in Java?
Show Answer
96) Which annotation indicates that a method is intended to override a method in a superclass?
Show Answer
97) What annotation suppresses compiler warnings?
Show Answer
98) Which class is used to measure elapsed time with nanosecond precision?
Show Answer
99) Which enum method returns an array of all defined enum constants?
Show Answer
100) What is the result of 1.0 / 0.0 in Java floating-point arithmetic?
Show Answer
No Comments