Java MCQ Questions
Java MCQs (Multiple Choice Questions) is a valuable resource for developers and students who want to test and strengthen their Java programming skills. Whether you're preparing for interviews, exams, or looking to improve your understanding of core concepts, our collection of Java MCQs offers a comprehensive selection. From basic syntax to advanced Java frameworks, the questions cover a wide range of topics that will help you build a strong foundation in Java programming. Stay ahead of the curve with these expert-curated MCQs designed to challenge and enhance your knowledge and problem-solving abilities.
Q1. What does JVM stand for in Java?
A. Java Variable Machine
B. Java Virtual Machine
C. Joint Virtual Method
D. Java Verified Module
📘 View Explanation
Q2. Which of the following is not a Java keyword?
A. class
B. interface
C. goto
D. string
📘 View Explanation
Q3. Which method is the entry point of a Java program?
A. start()
B. run()
C. main()
D. execute()
📘 View Explanation
Q4. Which data type is used to store decimal numbers in Java?
A. int
B. double
C. char
D. boolean
📘 View Explanation
Q5. What is the default value of a boolean variable in Java?
A. true
B. false
C. 0
D. null
📘 View Explanation
Q6. Which symbol is used for single-line comments in Java?
A. //
B. /* */
C. #
D. <!-- -->
📘 View Explanation
Q7. Which operator is used to compare two values in Java?
A. =
B. ==
C. !=
D. equals()
📘 View Explanation
Q8. Which keyword is used to inherit a class in Java?
A. this
B. super
C. extends
D. implements
📘 View Explanation
Q9. Which keyword is used to define a constant in Java?
A. const
B. static
C. final
D. constant
📘 View Explanation
Q10. Which Java keyword is used to create an object?
A. this
B. super
C. new
D. class
📘 View Explanation
Q11. Which of the following is a wrapper class in Java?
A. int
B. Integer
C. float
D. boolean
📘 View Explanation
Q12. Which method is used to get the length of a string in Java?
A. length()
B. size()
C. count()
D. len()
📘 View Explanation
Q13. Which package is imported by default in every Java program?
A. java.util
B. java.io
C. java.lang
D. java.sql
📘 View Explanation
Q14. Which exception occurs when dividing a number by zero in Java?
A. NullPointerException
B. ArithmeticException
C. IOException
D. NumberFormatException
📘 View Explanation
Q15. Which keyword is used to stop further inheritance of a class?
A. stop
B. constant
C. final
D. abstract
📘 View Explanation
Q16. Which keyword is used to create an interface in Java?
A. interface
B. abstract
C. implements
D. define
📘 View Explanation
Q17. Which Java collection class stores unique elements only?
A. List
B. Set
C. Map
D. ArrayList
📘 View Explanation
Q18. Which loop is guaranteed to execute at least once in Java?
A. for
B. while
C. do-while
D. foreach
📘 View Explanation
Q19. Which keyword is used for multiple inheritance in Java?
A. extends
B. interface
C. implements
D. inherit
📘 View Explanation
Q20. Which type of language is Java?
A. Compiled only
B. Interpreted only
C. Both compiled and interpreted
D. Scripting language
📘 View Explanation