Java is one of the most popular programming languages used in software development, competitive exams, and technical interviews. Java MCQ questions are commonly asked in exams, college tests, and placement interviews, making this topic very important for students and job aspirants.
In this blog post, we provide a well-organized collection of Java MCQ Questions and Answers to help beginners and experienced learners revise core Java concepts quickly. This content is designed especially for students, competitive exam aspirants, and interview candidates who want to strengthen their Java fundamentals.
Java MCQ Questions
1. Java is a:
- A) Procedure-oriented language
- B) Object-oriented language
- C) Assembly language
- D) Markup language
Explanation: Java is a purely object-oriented programming language (except primitive data types).
2. Which company originally developed Java?
- A) Microsoft
- B) Oracle
- C) Sun Microsystems
- D) IBM
Explanation: Java was originally developed by Sun Microsystems.
3. Which keyword is used to define a class in Java?
- A) class
- B) define
- C) struct
- D) new
Explanation: The
class keyword is used to define a class in Java.4. Which of the following is not a Java feature?
- A) Platform independent
- B) Object-oriented
- C) Use of pointers
- D) Secure
Explanation: Java does not support pointers to ensure security.
5. Java programs are compiled into:
- A) Machine code
- B) Bytecode
- C) Assembly code
- D) Source code
Explanation: Java compiler converts source code into bytecode.
6. Which method is the entry point of a Java program?
- A) start()
- B) run()
- C) main()
- D) init()
Explanation: Execution of Java program starts from the main() method.
7. Which keyword is used to inherit a class in Java?
- A) implement
- B) inherits
- C) extends
- D) super
Explanation: The
extends keyword is used for inheritance in Java.8. Which of the following is a valid Java data type?
- A) int
- B) float
- C) boolean
- D) All of the above
Explanation: int, float, and boolean are valid Java data types.
9. Which symbol is used to end a statement in Java?
- A) :
- B) .
- C) ;
- D) ,
Explanation: Semicolon (;) is used to terminate statements in Java.
10. Which of the following is used to create an object in Java?
- A) class
- B) object
- C) new
- D) create
Explanation: The
new keyword is used to create objects in Java.11. Which of the following is not an access modifier in Java?
- A) public
- B) private
- C) protected
- D) internal
Explanation: Java does not have an
internal access modifier.12. Which keyword is used to create a subclass?
- A) super
- B) this
- C) extends
- D) implements
Explanation:
extends is used to inherit a class in Java.13. Which keyword is used to implement an interface?
- A) extends
- B) implements
- C) interface
- D) inherit
Explanation: Interfaces are implemented using the
implements keyword.14. Which of the following is a non-primitive data type?
- A) int
- B) float
- C) char
- D) String
Explanation: String is a non-primitive (reference) data type in Java.
15. Which exception is thrown when dividing a number by zero?
- A) NullPointerException
- B) ArithmeticException
- C) NumberFormatException
- D) IOException
Explanation: Division by zero causes ArithmeticException.
16. Which block is always executed whether exception occurs or not?
- A) try
- B) catch
- C) throw
- D) finally
Explanation: The
finally block always executes.17. Which keyword is used to stop inheritance?
- A) static
- B) final
- C) abstract
- D) private
Explanation: A class declared as
final cannot be inherited.18. Which of the following is used to read input from keyboard?
- A) Scanner
- B) System.out
- C) PrintWriter
- D) FileReader
Explanation: Scanner class is commonly used for keyboard input.
19. Which package is automatically imported in every Java program?
- A) java.util
- B) java.io
- C) java.lang
- D) java.awt
Explanation: java.lang package is imported by default.
20. Which loop is guaranteed to execute at least once?
- A) for loop
- B) while loop
- C) do-while loop
- D) foreach loop
Explanation: do-while loop executes at least once before checking condition.
21. Which keyword is used to refer current object?
- A) this
- B) super
- C) self
- D) current
Explanation:
this refers to the current object.22. Which of the following is not a loop in Java?
- A) for
- B) while
- C) do-while
- D) repeat
Explanation: Java does not have a
repeat loop.23. Which keyword is used to create an abstract class?
- A) interface
- B) abstract
- C) virtual
- D) final
Explanation:
abstract keyword is used to declare abstract class.24. Which of the following is used to handle multiple exceptions?
- A) try
- B) finally
- C) multiple catch blocks
- D) throw
Explanation: Multiple catch blocks handle different exceptions.
25. Which concept allows method with same name but different parameters?
- A) Inheritance
- B) Polymorphism
- C) Encapsulation
- D) Abstraction
Explanation: Method overloading is an example of polymorphism.
26. Which keyword is used to define a constant?
- A) static
- B) const
- C) final
- D) constant
Explanation:
final is used to create constants in Java.27. Which class is parent of all Java classes?
- A) String
- B) Object
- C) Class
- D) System
Explanation: Object class is the superclass of all Java classes.
28. Which operator is used for comparison?
- A) =
- B) ==
- C) !=
- D) Both B and C
Explanation: == and != are comparison operators.
29. Which feature of Java supports code reusability?
- A) Polymorphism
- B) Inheritance
- C) Encapsulation
- D) Abstraction
Explanation: Inheritance allows reuse of existing code.
30. Which keyword is used to create a thread?
- A) thread
- B) Runnable
- C) start
- D) new
Explanation: The
start() method is used to start a thread.31. Which of the following is used to achieve abstraction in Java?
- A) Class
- B) Object
- C) Interface
- D) Constructor
Explanation: Interface is mainly used to achieve abstraction in Java.
32. Which keyword is used to handle exceptions manually?
- A) try
- B) catch
- C) throw
- D) throws
Explanation:
throw keyword is used to explicitly throw an exception.33. Which of the following is a checked exception?
- A) ArithmeticException
- B) NullPointerException
- C) IOException
- D) ArrayIndexOutOfBoundsException
Explanation: IOException is a checked exception.
34. Which statement is true about constructors?
- A) They have return type
- B) They can be inherited
- C) Name must be same as class
- D) They are static
Explanation: Constructor name must be same as class name.
35. Which access modifier allows access within the same package only?
- A) public
- B) private
- C) protected
- D) default
Explanation: Default access allows access within the same package only.
36. Which method is used to compare two strings?
- A) ==
- B) equals()
- C) compare()
- D) match()
Explanation: equals() method compares string values.
37. Which of the following is immutable in Java?
- A) String
- B) StringBuilder
- C) Array
- D) Object
Explanation: String objects are immutable in Java.
38. Which collection does not allow duplicate elements?
- A) List
- B) Set
- C) Map
- D) ArrayList
Explanation: Set does not allow duplicate elements.
39. Which class is used for dynamic arrays?
- A) Array
- B) Vector
- C) ArrayList
- D) LinkedList
Explanation: ArrayList provides dynamic array functionality.
40. Which keyword is used to synchronize threads?
- A) thread
- B) volatile
- C) synchronized
- D) wait
Explanation: synchronized keyword controls thread access.
41. Which method is used to stop a thread safely?
- A) stop()
- B) suspend()
- C) interrupt()
- D) end()
Explanation: interrupt() is the safe way to signal thread termination.
42. Which package contains collection framework?
- A) java.io
- B) java.util
- C) java.lang
- D) java.net
Explanation: Collection framework is present in java.util package.
43. Which keyword is used to call parent class constructor?
- A) this
- B) super
- C) parent
- D) base
Explanation: super keyword is used to call parent constructor.
44. Which of the following is not part of OOP?
- A) Encapsulation
- B) Inheritance
- C) Compilation
- D) Polymorphism
Explanation: Compilation is not an OOP concept.
45. Which operator is used for object reference comparison?
- A) equals()
- B) ==
- C) !=
- D) compareTo()
Explanation: == compares object references.
46. Which feature allows multiple inheritance in Java?
- A) Class
- B) Abstract class
- C) Interface
- D) Package
Explanation: Java supports multiple inheritance through interfaces.
47. Which class is used to take input from console?
- A) BufferedReader
- B) Scanner
- C) InputStream
- D) Both A and B
Explanation: Both BufferedReader and Scanner can take console input.
48. Which exception is thrown when array index is invalid?
- A) IOException
- B) ClassNotFoundException
- C) ArrayIndexOutOfBoundsException
- D) NumberFormatException
Explanation: Invalid array index causes ArrayIndexOutOfBoundsException.
49. Which Java feature makes it platform independent?
- A) Compiler
- B) JVM
- C) JDK
- D) JRE
Explanation: JVM enables Java to run on any platform.
50. Which type of memory is allocated at runtime?
- A) Stack
- B) Heap
- C) Static
- D) Register
Explanation: Objects are created in heap memory at runtime.
51. Which keyword is used to prevent method overriding?
- A) static
- B) private
- C) final
- D) abstract
Explanation: A method declared as
final cannot be overridden.52. Which of the following is not a Java keyword?
- A) static
- B) void
- C) then
- D) class
Explanation:
then is not a Java keyword.53. Which memory stores local variables?
- A) Heap
- B) Stack
- C) Static
- D) Method area
Explanation: Local variables are stored in stack memory.
54. Which method is used to start execution of a thread?
- A) run()
- B) start()
- C) execute()
- D) init()
Explanation: The
start() method starts a new thread.55. Which exception occurs when a null object is accessed?
- A) IOException
- B) ArithmeticException
- C) NullPointerException
- D) ClassNotFoundException
Explanation: Accessing a null reference throws NullPointerException.
56. Which collection allows key–value pairs?
- A) List
- B) Set
- C) Map
- D) Queue
Explanation: Map stores data in key–value pairs.
57. Which loop is best when number of iterations is known?
- A) while
- B) do-while
- C) for
- D) infinite loop
Explanation: for-loop is preferred when iterations are fixed.
58. Which keyword is used to define a package?
- A) package
- B) import
- C) include
- D) namespace
Explanation:
package keyword is used to create a package.59. Which keyword is used to access package classes?
- A) include
- B) extends
- C) import
- D) implements
Explanation:
import is used to access package classes.60. Which type of inheritance is not supported by Java classes?
- A) Single
- B) Multilevel
- C) Multiple
- D) Hierarchical
Explanation: Multiple inheritance is not supported using classes in Java.
61. Which method is called automatically when object is created?
- A) main()
- B) finalize()
- C) constructor
- D) init()
Explanation: Constructor is invoked automatically during object creation.
62. Which keyword is used to inherit interfaces?
- A) implements
- B) extends
- C) inherits
- D) interface
Explanation: One interface inherits another using
extends.63. Which of the following is mutable?
- A) String
- B) StringBuilder
- C) Integer
- D) Character
Explanation: StringBuilder objects are mutable.
64. Which class is used for file reading?
- A) FileWriter
- B) FileInputStream
- C) FileReader
- D) PrintWriter
Explanation: FileReader is used to read character files.
65. Which method releases resources before object destruction?
- A) destroy()
- B) free()
- C) finalize()
- D) delete()
Explanation: finalize() is called by garbage collector before object removal.
66. Which operator is used for logical AND?
- A) &
- B) &&
- C) |
- D) ||
Explanation: && is the logical AND operator.
67. Which class is thread-safe?
- A) ArrayList
- B) HashMap
- C) Vector
- D) HashSet
Explanation: Vector methods are synchronized by default.
68. Which exception is thrown when class is not found?
- A) IOException
- B) ClassNotFoundException
- C) SQLException
- D) RuntimeException
Explanation: ClassNotFoundException occurs when class is missing.
69. Which concept binds data and methods together?
- A) Inheritance
- B) Abstraction
- C) Encapsulation
- D) Polymorphism
Explanation: Encapsulation binds data and methods into a single unit.
70. Which Java component runs bytecode?
- A) JDK
- B) JRE
- C) JVM
- D) Compiler
Explanation: JVM executes Java bytecode.
71. Which keyword is used to call parent class constructor?
- A) this
- B) super
- C) parent
- D) base
Explanation:
super keyword is used to call the parent class constructor.72. Which Java feature allows same method name with different parameters?
- A) Overriding
- B) Abstraction
- C) Overloading
- D) Encapsulation
Explanation: Method overloading allows same method name with different parameters.
73. Which access modifier allows access within same package only?
- A) public
- B) private
- C) protected
- D) default
Explanation: Default access modifier restricts access within same package.
74. Which keyword is used to create an object?
- A) class
- B) object
- C) new
- D) create
Explanation:
new keyword is used to create an object in Java.75. Which interface provides sorting capability?
- A) Runnable
- B) Serializable
- C) Comparable
- D) Cloneable
Explanation: Comparable interface is used to sort objects.
76. Which statement is used to handle exceptions?
- A) throw
- B) throws
- C) try-catch
- D) finally
Explanation: try-catch block is used to handle exceptions.
77. Which Java version introduced lambda expressions?
- A) Java 5
- B) Java 6
- C) Java 7
- D) Java 8
Explanation: Lambda expressions were introduced in Java 8.
78. Which class is parent of all exceptions?
- A) RuntimeException
- B) Throwable
- C) Exception
- D) Error
Explanation: Throwable is the superclass of all exceptions and errors.
79. Which package contains Scanner class?
- A) java.io
- B) java.util
- C) java.lang
- D) java.sql
Explanation: Scanner class belongs to java.util package.
80. Which keyword is used to stop inheritance?
- A) static
- B) private
- C) final
- D) abstract
Explanation: final keyword prevents inheritance.
81. Which loop executes at least once?
- A) for
- B) while
- C) do-while
- D) infinite
Explanation: do-while loop executes at least once.
82. Which class is immutable?
- A) String
- B) StringBuilder
- C) StringBuffer
- D) ArrayList
Explanation: String objects are immutable in Java.
83. Which operator is used to compare two values?
- A) =
- B) ==
- C) !=
- D) equals
Explanation: == operator compares two values for equality.
84. Which keyword is used to define constant?
- A) static
- B) constant
- C) final
- D) const
Explanation: final keyword is used to define constants.
85. Which class is used to write data to file?
- A) FileReader
- B) BufferedReader
- C) FileWriter
- D) Scanner
Explanation: FileWriter is used to write data into files.
86. Which collection does not allow duplicates?
- A) List
- B) Set
- C) Map
- D) ArrayList
Explanation: Set does not allow duplicate elements.
87. Which method is entry point of Java program?
- A) start()
- B) init()
- C) run()
- D) main()
Explanation: main() method is the entry point of Java program.
88. Which keyword is used for interface implementation?
- A) extends
- B) implements
- C) inherit
- D) interface
Explanation: implements keyword is used to implement an interface.
89. Which exception is unchecked?
- A) IOException
- B) SQLException
- C) ClassNotFoundException
- D) ArithmeticException
Explanation: ArithmeticException is an unchecked exception.
90. Which Java component is platform dependent?
- A) Java source code
- B) Bytecode
- C) JVM
- D) JDK
Explanation: JVM is platform dependent, making Java platform independent.
91. Which keyword is used to refer current class object?
- A) super
- B) this
- C) self
- D) object
Explanation:
this keyword refers to the current class object.92. Which Java feature supports runtime polymorphism?
- A) Method overloading
- B) Method overriding
- C) Constructor overloading
- D) Static binding
Explanation: Method overriding enables runtime polymorphism.
93. Which keyword is used to declare an abstract class?
- A) virtual
- B) abstract
- C) final
- D) interface
Explanation:
abstract keyword is used to declare abstract class.94. Which stream is used for byte-oriented file output?
- A) FileReader
- B) FileWriter
- C) FileOutputStream
- D) BufferedReader
Explanation: FileOutputStream writes byte data to files.
95. Which class provides synchronized string operations?
- A) String
- B) StringBuilder
- C) StringBuffer
- D) CharSequence
Explanation: StringBuffer methods are synchronized and thread-safe.
96. Which collection maintains insertion order?
- A) HashSet
- B) TreeSet
- C) LinkedHashSet
- D) PriorityQueue
Explanation: LinkedHashSet maintains insertion order.
97. Which exception occurs when array index is invalid?
- A) NullPointerException
- B) ArithmeticException
- C) ArrayIndexOutOfBoundsException
- D) ClassCastException
Explanation: Invalid array index throws ArrayIndexOutOfBoundsException.
98. Which keyword is used to create subclass?
- A) implements
- B) extends
- C) inherits
- D) super
Explanation:
extends keyword creates a subclass.99. Which Java API is used for database connectivity?
- A) JPA
- B) JDBC
- C) RMI
- D) JNDI
Explanation: JDBC is used to connect Java with databases.
100. Which access modifier has the widest scope?
- A) private
- B) default
- C) protected
- D) public
Explanation: public members are accessible everywhere.
101. Which method is used to compare strings ignoring case?
- A) equals()
- B) compare()
- C) equalsIgnoreCase()
- D) compareTo()
Explanation: equalsIgnoreCase() ignores case while comparison.
102. Which keyword is used to handle checked exceptions?
- A) try
- B) catch
- C) throws
- D) finally
Explanation: throws keyword declares checked exceptions.
103. Which interface is used to create thread?
- A) Serializable
- B) Runnable
- C) Cloneable
- D) Callable
Explanation: Runnable interface is commonly used to create threads.
104. Which collection allows duplicate elements?
- A) Set
- B) Map
- C) List
- D) TreeSet
Explanation: List allows duplicate elements.
105. Which method converts string to integer?
- A) Integer.valueOf()
- B) parseInt()
- C) toInt()
- D) convert()
Explanation: parseInt() converts String to int.
106. Which class is used to format date?
- A) Date
- B) Calendar
- C) DateFormat
- D) LocalDate
Explanation: DateFormat formats date and time.
107. Which Java feature supports code reusability?
- A) Encapsulation
- B) Inheritance
- C) Abstraction
- D) Polymorphism
Explanation: Inheritance enables code reusability.
108. Which operator is used for object reference comparison?
- A) equals()
- B) ==
- C) !=
- D) instanceof
Explanation: == compares object references.
109. Which package is imported by default?
- A) java.util
- B) java.io
- C) java.lang
- D) java.net
Explanation: java.lang package is imported by default.
110. Which keyword is used to check object type?
- A) typeof
- B) instance
- C) instanceof
- D) istype
Explanation: instanceof checks object type at runtime.
We hope these Java MCQ Questions and Answers help you revise important concepts and improve your confidence for exams and interviews. Regular practice of MCQs is one of the best ways to master Java fundamentals.
For more programming MCQs, interview questions, and exam-oriented study material, keep visiting our website and share this post with your friends and classmates.