Learn JAVA MCQs
Prepare JAVA MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is a wrapper class in Java?
1) int
2) float
3) Integer
4) char
Answer : Integer
Which of the following statements is correct about Java?
1) Java is a platform-independent language.
2) Java supports multiple inheritance through classes.
3) Java does not support exception handling.
4) None of the above
Answer : Java is a platform-independent language.
Which of the following can be used to define a constant in Java?
1) final
2) const
3) static
4) volatile
Answer : final
What will be the output of System.out.println(10 / 0);?
1) Infinity
2) NaN
3) Throws ArithmeticException
4) None of the above
Answer : Throws ArithmeticException
Which of the following is used to create a thread in Java?
1) Runnable interface
2) Thread class
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2
What is the return type of the main method in Java?
1) void
2) int
3) String
4) None of the above
Answer : void
Which of the following is a reserved keyword in Java?
1) goto
2) switch
3) break
4) All of the above
Answer : goto
Which of the following is used for input in Java?
1) Scanner
2) BufferedReader
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2
Which method must be implemented by all threads in Java?
1) run()
2) start()
3) stop()
4) None of the above
Answer : run()
Which operator is used to compare two objects in Java?
1) ==
2) equals()
3) Both 1 and 2
4) None of the above
Answer : equals()