Java Basics MCQs for Developer Interviews & Certification

1 min read

Java is a high-level, class-based, object-oriented programming language designed on the “Write Once, Run Anywhere” (WORA) philosophy enabled by the Java Virtual Machine (JVM). Mastering Java basics requires a solid understanding of its core runtime architecture comprising the JDK, JRE, and JVM alongside fundamental syntax rules, primitive data types, control flow structures, and object-oriented principles. From defining the standard main entry point method to handling arrays, strings, access modifiers, and basic exception handling, a firm grasp of Java fundamentals is essential for software development and technical coding assessments.

1. Which component is responsible for executing bytecode in Java?

a) Java Compiler
b) Java Virtual Machine
c) Java Development Kit
d) Java Application Programming Interface
Correct Answer: b) Java Virtual Machine
Explanation:
The Java Virtual Machine (JVM) executes Java bytecode and provides machine independence.

2. Which of the following is not a primitive data type in Java?

a) int
b) boolean
c) String
d) char
Correct Answer: c) String
Explanation:
String is a built-in reference class type, whereas int, boolean, and char are primitive types.

3. What is the default value of a local variable in Java?

a) 0
b) null
c) false
d) No default value
Correct Answer: d) No default value
Explanation:
Local variables do not receive a default value and must be explicitly initialized before use.

4. Which of these access specifiers can be used for a top-level class in Java?

a) public and default
b) private and protected
c) private, protected, public, and default
d) public and protected only
Correct Answer: a) public and default
Explanation:
Outer classes in Java can only have public or default (package-private) access modifiers.

5. Which method must be implemented by all threads in Java?

a) start()
b) run()
c) execute()
d) init()
Correct Answer: b) run()
Explanation:
The run() method contains the code executed by a thread and is required by the Runnable interface.

6. What is the size of an int data type in Java?

a) 2 bytes
b) 4 bytes
c) 8 bytes
d) 16 bytes
Correct Answer: b) 4 bytes
Explanation:
An int in Java is a 32-bit signed integer, occupying 4 bytes of memory.

7. Which package contains the Scanner class for reading user input?

a) java.io
b) java.util
c) java.net
d) java.lang
Correct Answer: b) java.util
Explanation:
The Scanner class is located within the java.util package.

8. Which keyword is used to inherit a class in Java?

a) implements
b) extends
c) inherits
d) super
Correct Answer: b) extends
Explanation:
The extends keyword is used in class declarations to inherit from a superclass.

9. What is the return type of the hashCode() method in Java?

a) long
b) int
c) void
d) String
Correct Answer: b) int
Explanation:
The hashCode() method returns an integer hash code value for the object.

10. Which exception is thrown when an attempt is made to divide by zero with integers?

a) NullPointerException
b) ArithmeticException
c) NumberFormatException
d) IllegalArgumentException
Correct Answer: b) ArithmeticException
Explanation:
Dividing an integer by zero triggers an unchecked ArithmeticException.

11. Which loop guarantees that its body will execute at least once?

a) for loop
b) while loop
c) do-while loop
d) foreach loop
Correct Answer: c) do-while loop
Explanation:
A do-while loop evaluates its condition after executing the body, ensuring it runs at least once.

12. Which of the following is a marker interface?

a) Runnable
b) Comparable
c) Serializable
d) Iterator
Correct Answer: c) Serializable
Explanation:
Serializable is a marker interface because it contains no methods and signals metadata to the JVM.

13. What does JDK stand for?

a) Java Development Kit
b) Java Deployment Kit
c) Java Document Key
d) Java Data Kernel
Correct Answer: a) Java Development Kit
Explanation:
JDK stands for Java Development Kit, which includes tools needed to develop and run Java programs.

14. Which operator is used to compare two values for equality in Java?

a) =
b) ==
c) equals()
d) is
Correct Answer: b) ==
Explanation:
The == operator is used to compare primitive values or object reference addresses for equality.

15. Which class is the superclass of all classes in Java?

a) System
b) Object
c) Class
d) String
Correct Answer: b) Object
Explanation:
Every class in Java implicitly inherits from the java.lang.Object class.

16. What is the output of System.out.println(10 + 20 + "Hello");?

a) 1020Hello
b) 30Hello
c) 1030Hello
d) Hello30
Correct Answer: b) 30Hello
Explanation:
Java evaluates addition from left to right; 10 + 20 is calculated as 30, then concatenated with "Hello".

17. Which keyword prevents a method from being overridden?

a) static
b) final
c) abstract
d) private
Correct Answer: b) final
Explanation:
Declaring a method as final ensures subclasses cannot override it.

18. What is the range of a byte data type in Java?

a) -128 to 127
b) -32768 to 32767
c) 0 to 255
d) -256 to 255
Correct Answer: a) -128 to 127
Explanation:
A byte is an 8-bit signed integer, ranging from -128 to 127.

19. Which collection allows duplicate elements and maintains insertion order?

a) HashSet
b) TreeSet
c) ArrayList
d) HashMap
Correct Answer: c) ArrayList
Explanation:
ArrayList is an ordered list collection that permits duplicate elements.

20. Which of the following is a checked exception in Java?

a) NullPointerException
b) IOException
c) ArithmeticException
d) ArrayIndexOutOfBoundsException
Correct Answer: b) IOException
Explanation:
IOException is a checked exception that must be caught or declared in the method signature.

21. How do you create a single-line comment in Java?

a) /* Comment */
b) <!-- Comment -->
c) // Comment
d) # Comment
Correct Answer: c) // Comment
Explanation:
Single-line comments in Java start with double forward slashes (//).

22. Which modifier makes a variable accessible only within its own class?

a) public
b) protected
c) private
d) default
Correct Answer: c) private
Explanation:
The private access modifier restricts visibility strictly to the enclosing class.

23. What is the default value of a boolean variable in an instance field?

a) true
b) false
c) null
d) 0
Correct Answer: b) false
Explanation:
Instance variables of type boolean are initialized to false by default.

24. Which method is used to start the execution of a thread?

a) run()
b) start()
c) init()
d) begin()
Correct Answer: b) start()
Explanation:
Calling the start() method creates a new thread execution context and then calls the run() method.

25. Which wrapper class corresponds to the primitive type char?

a) Character
b) Char
c) String
d) Text
Correct Answer: a) Character
Explanation:
Character is the wrapper class for the primitive char data type.

26. What is polymorphism in Java primarily achieved through?

a) Method overloading and method overriding
b) Inheritance and encapsulation
c) Interfaces only
d) Packages and imports
Correct Answer: a) Method overloading and method overriding
Explanation:
Polymorphism is realized via compile-time (overloading) and runtime (overriding) polymorphism.

27. Which keyword is used to explicitly throw an exception?

a) throws
b) throw
c) catch
d) finally
Correct Answer: b) throw
Explanation:
The throw keyword is used to trigger an exception instance manually.

28. Which statement about interfaces is true?

a) Interfaces can contain method bodies by default (since Java 8).
b) Interfaces can be instantiated directly using new.
c) Interfaces support multiple inheritance for classes.
d) All fields in an interface are non-static.
Correct Answer: a) Interfaces can contain method bodies by default (since Java 8).
Explanation:
Since Java 8, interfaces can contain default and static methods with method bodies.

29. What is the extension of compiled Java bytecode files?

a) .java
b) .class
c) .js
d) .jar
Correct Answer: b) .class
Explanation:
The Java compiler compiles source files (.java) into bytecode files (.class).

30. Which collection stores key-value pairs with unique keys?

a) List
b) Set
c) Map
d) Queue
Correct Answer: c) Map
Explanation:
A Map interface maps unique keys to corresponding values.

31. What is the output of System.out.println(5 >> 1);?

a) 2
b) 10
c) 2.5
d) 1
Correct Answer: a) 2
Explanation:
The signed right shift operator (>>) divides the number by 2 to the power of 1. 5 / 2 = 2 using integer division.

32. Which method compares two Strings for content equality?

a) ==
b) equals()
c) compareTo()
d) match()
Correct Answer: b) equals()
Explanation:
The equals() method compares the actual character contents of two String objects.

33. Which class is mutable for string manipulation?

a) String
b) StringBuilder
c) Character
d) System
Correct Answer: b) StringBuilder
Explanation:
StringBuilder provides a mutable sequence of characters.

34. Which package is imported automatically in every Java program?

a) java.util
b) java.io
c) java.lang
d) java.net
Correct Answer: c) java.lang
Explanation:
The java.lang package contains fundamental classes and is imported implicitly by the compiler.

35. What happens when an exception is thrown and not caught anywhere?

a) The program ignores it.
b) The program terminates and prints a stack trace.
c) The compiler throws a syntax error.
d) The OS reboots.
Correct Answer: b) The program terminates and prints a stack trace.
Explanation:
An uncaught exception causes the thread to terminate and print its stack trace to standard error.

36. Which modifier restricts a variable from being serialized?

a) static
b) transient
c) volatile
d) final
Correct Answer: b) transient
Explanation:
The transient keyword instructs the JVM to skip a field during object serialization.

37. What is the size of a float data type in Java?

a) 2 bytes
b) 4 bytes
c) 8 bytes
d) 16 bytes
Correct Answer: b) 4 bytes
Explanation:
A float is a 32-bit single-precision floating-point number, occupying 4 bytes.

38. Which of these keywords is used to refer to the current object?

a) super
b) this
c) self
d) base
Correct Answer: b) this
Explanation:
The this keyword acts as a reference to the current object instance.

39. What is autoboxing in Java?

a) Converting a primitive type to its corresponding wrapper class object automatically.
b) Converting an object to a primitive type automatically.
c) Casting a subclass reference to a superclass reference.
d) Automatic memory cleanup by the garbage collector.
Correct Answer: a) Converting a primitive type to its corresponding wrapper class object automatically.
Explanation:
Autoboxing is the automatic conversion made by the Java compiler between primitives and wrapper objects.

40. Which of the following sorting mechanisms is used by TreeSet?

a) Random order
b) Insertion order
c) Natural sorting order
d) Reverse insertion order
Correct Answer: c) Natural sorting order
Explanation:
A TreeSet stores elements in sorted order according to their natural ordering or a custom Comparator.

41. Which keyword is used to handle exceptions in Java?

a) try-catch
b) handle-err
c) test-rescue
d) detect-fix
Correct Answer: a) try-catch
Explanation:
The try-catch block structure is used to catch and handle runtime exceptions gracefully.

42. What is the default value of an object reference variable in Java?

a) 0
b) false
c) null
d) undefined
Correct Answer: c) null
Explanation:
Uninitialized instance and class reference variables default to null.

43. Which operator has the highest precedence in Java?

a) Assignment (=)
b) Logical AND (&&)
c) Postfix increment/decrement (++ / --)
d) Arithmetic addition (+)
Correct Answer: c) Postfix increment/decrement (++ / --)
Explanation:
Postfix operators have very high precedence compared to binary arithmetic, logical, or assignment operators.

44. What is the purpose of the break statement inside a switch block?

a) To exit the loop or switch block entirely.
b) To skip the current iteration.
c) To throw an exception.
d) To restart the program.
Correct Answer: a) To exit the loop or switch block entirely.
Explanation:
A break statement stops execution from falling through to subsequent case labels in a switch statement.

45. Which class is used to write character streams to a file?

a) FileInputStream
b) FileWriter
c) FileOutputStream
d) BufferedReader
Correct Answer: b) FileWriter
Explanation:
FileWriter is a convenience class for writing character data to files.

46. Which of the following is a valid identifier name in Java?

a) 123var
b) -variable
c) _myVar1
d) class
Correct Answer: c) _myVar1
Explanation:
Identifiers can begin with letters, currency symbols, or underscores (_), but cannot start with digits or keywords.

47. What is the primary function of the Garbage Collector in Java?

a) To delete .class files after execution
b) To automatically free memory occupied by unreferenced objects
c) To clean up syntax errors during compilation
d) To delete temporary log files
Correct Answer: b) To automatically free memory occupied by unreferenced objects
Explanation:
The garbage collector handles dynamic memory management by reclaiming memory from unreachable objects.

48. Which keyword can be used to access superclass methods or constructors?

a) this
b) super
c) parent
d) base
Correct Answer: b) super
Explanation:
The super keyword is used to reference members of a direct superclass.

49. What does JRE stand for?

a) Java Runtime Environment
b) Java Rapid Execution
c) Java Resource Engine
d) Java Remote Execution
Correct Answer: a) Java Runtime Environment
Explanation:
JRE stands for Java Runtime Environment, which contains the JVM and core libraries.

50. Which method signature represents the standard Java main method?

a) public static void main(String[] args)
b) public void main(String args)
c) static void main()
d) public int main(String[] args)
Correct Answer: a) public static void main(String[] args)
Explanation:
The standard entry point for any standalone Java application is public static void main(String[] args).

51. Which of the following statements about constructors is false?

a) Constructors have the same name as the class.
b) Constructors can return a value like int or void.
c) Constructors are called automatically when an object is created.
d) A class can have multiple constructors (constructor overloading).
Correct Answer: b) Constructors can return a value like int or void.
Explanation:
Constructors do not have a return type, not even void.

52. Which logical operator represents logical OR in Java?

a) &&
b) ||
c) !
d) &
Correct Answer: b) ||
Explanation:
The double pipe (||) represents the conditional logical OR operator.

53. What is the size of a long data type in Java?

a) 4 bytes
b) 8 bytes
c) 2 bytes
d) 16 bytes
Correct Answer: b) 8 bytes
Explanation:
A long integer is 64 bits, taking 8 bytes of memory.

54. Which interface does the ArrayList class implement?

a) Map
b) Set
c) List
d) Queue
Correct Answer: c) List
Explanation:
ArrayList implements the java.util.List interface.

55. Which keyword makes a variable constant and unchangeable once assigned?

a) static
b) constant
c) final
d) immutable
Correct Answer: c) final
Explanation:
The final keyword prevents a variable's value from being modified after initial assignment.

56. What happens when you pass an array to a method in Java?

a) A deep copy of the array is passed.
b) A reference to the array object is passed by value.
c) The array elements are copied by value.
d) It causes a compilation error.
Correct Answer: b) A reference to the array object is passed by value.
Explanation:
Java passes all arguments by value, which means the reference pointing to the array object is copied.

57. Which exception is thrown when trying to access an array index that is out of bounds?

a) IndexOutOfBoundsException
b) ArrayIndexOutOfBoundsException
c) NullPointerException
d) ArrayStoreException
Correct Answer: b) ArrayIndexOutOfBoundsException
Explanation:
Accessing an invalid array index triggers an ArrayIndexOutOfBoundsException.

58. Which field or method is used to find the length of an array in Java?

a) length() method
b) length field
c) size() method
d) getSize() method
Correct Answer: b) length field
Explanation:
Arrays in Java use a public final field named length to obtain their size.

59. Which keyword is used to define an abstract class?

a) interface
b) virtual
c) abstract
d) implements
Correct Answer: c) abstract
Explanation:
An abstract class is declared using the abstract keyword.

60. What is the primary feature of encapsulation?

a) Hiding internal data and exposing operations via methods
b) Inheriting properties from parent classes
c) Writing multiple methods with the same name
d) Executing code concurrently
Correct Answer: a) Hiding internal data and exposing operations via methods
Explanation:
Encapsulation wraps data and code together, restricting direct external access to fields.

61. Which class is used for reading text streams from character-input streams efficiently?

a) FileReader
b) BufferedReader
c) Scanner
d) InputStreamReader
Correct Answer: b) BufferedReader
Explanation:
BufferedReader buffers input for efficient reading of characters, arrays, and lines.

62. Which method can be used to convert a string representation to an integer in Java?

a) Integer.parseInt()
b) String.toInt()
c) Integer.valueOfString()
d) Convert.toInt()
Correct Answer: a) Integer.parseInt()
Explanation:
Integer.parseInt() parses string input and returns a primitive int.

63. Which of these access levels allows visibility across different packages through subclassing?

a) private
b) default
c) protected
d) none of the above
Correct Answer: c) protected
Explanation:
Protected members are accessible within the same package and by subclasses in other packages.

64. What is the output of System.out.println(10 == 10.0); in Java?

a) false
b) true
c) Compilation error
d) Runtime error
Correct Answer: b) true
Explanation:
Numeric primitive comparisons promote operands, so 10 is equal to 10.0, evaluating to true.

65. Which method is part of the java.lang.Object class?

a) clone()
b) compareTo()
c) size()
d) hasNext()
Correct Answer: a) clone()
Explanation:
clone() is a protected method defined in Object.

66. Which of the following describes method overloading?

a) Methods with the same name and same parameter list in different classes
b) Methods with the same name but different parameter lists within the same class
c) Overriding a superclass method in a subclass
d) Changing the return type only of a method
Correct Answer: b) Methods with the same name but different parameter lists within the same class
Explanation:
Method overloading occurs when multiple methods share a name but differ in their parameters.

67. What is the purpose of the finally block in exception handling?

a) To catch any unexpected errors
b) To execute cleanup code regardless of whether an exception occurred
c) To re-throw caught exceptions
d) To stop program execution immediately
Correct Answer: b) To execute cleanup code regardless of whether an exception occurred
Explanation:
The finally block always executes after the try-catch block completes, making it ideal for resource cleanup.

68. Which statement is true regarding static variables?

a) They belong to individual object instances.
b) They are shared among all instances of a class.
c) They cannot be accessed without creating an object.
d) They must be declared inside methods.
Correct Answer: b) They are shared among all instances of a class.
Explanation:
Static fields belong to the class itself rather than any specific instance.

69. Which of these is NOT a core pillar of Object-Oriented Programming?

a) Compilation
b) Encapsulation
c) Inheritance
d) Polymorphism
Correct Answer: a) Compilation
Explanation:
The core pillars of OOP are Encapsulation, Inheritance, Polymorphism, and Abstraction.

70. What is unboxing?

a) Converting a wrapper object to its corresponding primitive type
b) Converting a primitive type to a wrapper object
c) Unpacking a zip file programmatically
d) Casting an interface to a class
Correct Answer: a) Converting a wrapper object to its corresponding primitive type
Explanation:
Unboxing is the automatic extraction of a primitive value from a wrapper object.

71. Which keyword is used to prevent inheritance of a class?

a) static
b) final
c) private
d) sealed
Correct Answer: b) final
Explanation:
A final class cannot be extended by any subclass.

72. What is the default value of a float instance variable?

a) 0.0
b) 0.0f
c) 0
d) null
Correct Answer: b) 0.0f
Explanation:
Uninitialized float fields default to 0.0f.

73. Which package should be imported to use utility data structures like HashMap and ArrayList?

a) java.io
b) java.util
c) java.net
d) java.sql
Correct Answer: b) java.util
Explanation:
The Collections Framework classes reside in the java.util package.

74. Which of the following is true about a constructor?

a) It can be explicitly called like a normal method.
b) It is invoked automatically when an object is instantiated using new.
c) It must always be declared as private.
d) It cannot accept parameters.
Correct Answer: b) It is invoked automatically when an object is instantiated using new.
Explanation:
Constructors run automatically during object instantiation via the new keyword.

75. Which statement can be used to terminate a loop prematurely?

a) stop
b) exit
c) break
d) return
Correct Answer: c) break
Explanation:
The break statement exits the enclosing loop immediately.

76. What does the continue statement do in a loop?

a) Terminates the loop entirely
b) Skips the remaining statements in the current iteration and proceeds to the next iteration
c) Restarts the loop from the beginning
d) Pauses thread execution
Correct Answer: b) Skips the remaining statements in the current iteration and proceeds to the next iteration
Explanation:
Continue skips the rest of the current loop iteration and moves directly to the next iteration.

77. Which interface represents an ordered collection that allows positional access by index?

a) Set
b) List
c) Map
d) Queue
Correct Answer: b) List
Explanation:
The List interface maintains element order and allows access via integer indices.

78. Which of these can be used as a legal array declaration in Java?

a) int arr[];
b) int[] arr;
c) Both a and b
d) int arr[5];
Correct Answer: c) Both a and b
Explanation:
Both int arr[] and int[] arr are syntactically valid array declarations in Java.

79. What is the output of System.out.println(Math.floor(3.9));?

a) 4.0
b) 3.0
c) 3
d) 4
Correct Answer: b) 3.0
Explanation:
Math.floor() returns the largest double value less than or equal to the argument.

80. Which keyword is used to define a constant value in Java?

a) const
b) final
c) static final
d) immutable
Correct Answer: c) static final
Explanation:
Constants in Java are typically defined using static final.

81. What is the primary difference between String and StringBuffer?

a) String is mutable, StringBuffer is immutable.
b) String is immutable, StringBuffer is mutable.
c) StringBuffer cannot be used in multi-threaded environments.
d) There is no difference.
Correct Answer: b) String is immutable, StringBuffer is mutable.
Explanation:
String objects cannot be changed after creation, whereas StringBuffer objects can be modified.

82. Which of the following is a wrapper class for int?

a) Int
b) Integer
c) Number
d) Digit
Correct Answer: b) Integer
Explanation:
Integer is the wrapper class for primitive int.

83. What is the range of values for a char data type in Java?

a) 0 to 32767
b) -128 to 127
c) 0 to 65535
d) -32768 to 32767
Correct Answer: c) 0 to 65535
Explanation:
A char in Java is 16 bits unsigned, representing Unicode characters from 0 to 65535.

84. Which method is used to obtain the number of elements in a HashMap?

a) length()
b) size()
c) count()
d) capacity()
Correct Answer: b) size()
Explanation:
The size() method returns the number of key-value mappings in a map.

85. Which of these operators is used for bitwise AND?

a) &&
b) &
c) |
d) ^
Correct Answer: b) &
Explanation:
The single ampersand (&) is used for bitwise AND operations.

86. What does JVM stand for?

a) Java Virtual Machine
b) Java Visual Model
c) Java Verified Module
d) Java Variable Machine
Correct Answer: a) Java Virtual Machine
Explanation:
JVM stands for Java Virtual Machine.

87. Which of the following classes is thread-safe?

a) ArrayList
b) HashMap
c) StringBuffer
d) StringBuilder
Correct Answer: c) StringBuffer
Explanation:
StringBuffer methods are synchronized, making it thread-safe, unlike StringBuilder.

88. Which of the following is a valid method signature for a main method that accepts command-line arguments?

a) public static void main(String args[])
b) static public void main(String[] args)
c) public static void main(String... args)
d) All of the above
Correct Answer: d) All of the above
Explanation:
Java accepts array brackets placement flexibility and varargs for the main method signature.

89. What is the return type of the equals() method in Java?

a) int
b) boolean
c) void
d) String
Correct Answer: b) boolean
Explanation:
The equals() method returns true if objects match content, and false otherwise.

90. Which keyword is used to create an instance of a class?

a) create
b) new
c) instance
d) alloc
Correct Answer: b) new
Explanation:
The new keyword allocates memory and invokes the constructor to create an object.

91. Which of these is a valid declaration for a double variable?

a) double d = 45.50;
b) double d = 45.50f;
c) double d = "45.50";
d) double d = true;
Correct Answer: a) double d = 45.50;
Explanation:
Literal floating-point numbers default to double type in Java.

92. What is the outcome of attempting to compile and run a class without a main method?

a) Compilation error
b) Runtime error: NoSuchMethodError: main
c) It runs successfully and exits.
d) Warning message only
Correct Answer: b) Runtime error: NoSuchMethodError: main
Explanation:
The compiler accepts classes without main, but the JVM throws a NoSuchMethodError when execution starts.

93. Which keyword is used within a subclass constructor to invoke its superclass constructor?

a) this()
b) super()
c) parent()
d) base()
Correct Answer: b) super()
Explanation:
super() calls the constructor of the immediate superclass.

94. Which of the following packages contains classes for multithreading and concurrency utilities?

a) java.util.concurrent
b) java.thread
c) java.process
d) java.net
Correct Answer: a) java.util.concurrent
Explanation:
Advanced concurrency utilities are located in java.util.concurrent.

95. What is method overriding?

a) Defining a method in a subclass with the same signature as in its superclass
b) Defining multiple methods with the same name in the same class
c) Changing the access modifier of a private method
d) Deleting a method from a superclass
Correct Answer: a) Defining a method in a subclass with the same signature as in its superclass
Explanation:
Method overriding allows a subclass to provide a specific implementation of a method defined in its superclass.

96. Which symbol is used for single-line comments in Java source code?

a) #
b) --
c) //
d) /*
Correct Answer: c) //
Explanation:
Double slashes (//) designate single-line comments.

97. Which data structure is best described as a LIFO (Last-In-First-Out) stack?

a) Queue
b) Stack
c) ArrayList
d) LinkedList
Correct Answer: b) Stack
Explanation:
A Stack operates on a LIFO principle.

98. What is the purpose of an abstract method?

a) To provide a complete body that subclasses cannot change
b) To declare a method signature without a body, forcing subclasses to implement it
c) To run code asynchronously
d) To optimize memory usage
Correct Answer: b) To declare a method signature without a body, forcing subclasses to implement it
Explanation:
Abstract methods lack bodies and mandate implementation in non-abstract subclasses.

99. Which of these is a valid declaration for a constant integer?

a) final int MAX = 100;
b) const int MAX = 100;
c) static int MAX = 100;
d) immutable int MAX = 100;
Correct Answer: a) final int MAX = 100;
Explanation:
The final keyword makes the integer variable unassignable after initial assignment.
← Previous: Java Advanced MCQs
Next →: Java Collections Frame Work MCQs
C++ Variables & Data Types MCQs

C++ Variables & Data Types MCQs

Variables and data types form the core building blocks of any C++ application, defining how data is stored, represented, and…

By MCQs Generator
Python Tuples & sets MCQs

Python Tuples & Sets MCQs

Python tuples and sets are fundamental built-in data structures used to store collections of items with distinct characteristics. Tuples are…

By MCQs Generator
Java Exception Handling MCQs

Java Exception Handling MCQs

Java exception handling is a powerful mechanism designed to manage runtime errors and maintain normal application flow. It relies on…

By MCQs Generator