Java MCQ Questions and Answers
Java MCQ questions with answers are essential for mastering object-oriented programming concepts and preparing for placement exams. These programming questions and answers commonly appear in company-wise interview tests like TCS, Infosys, and Wipro. Topics include data types, inheritance, interfaces, exception handling, and multithreading. Practicing Java MCQ online enhances coding logic, syntax accuracy, and problem-solving ability. Students can also download Java programming questions with solutions PDF to reinforce learning before interviews and coding assessments.
Java MCQ
Showing 10 of
22 questions
1. What output is displayed as the result of executing the following statement? System.out.println("// Looks like a comment.");
- // Looks like a comment
- The statement results in a compilation error
- Looks like a comment
- No output is displayed
2. In order for a source code file, containing the public class Test, to successfully compile, which of the following must be true?
- It must have a package statement
- It must be named Test.java
- It must import java.lang
- It must declare a public class named Test
3. Which of the following declare an array of string objects? a)String[ ] s; b) String [ ]s: c)String[ s]: d) String s[ ]:
- a& b
- a,b& c
- c&a
- a,b& d
4. What is the value of a[3] as the result of the following array declaration?
- 1
- 2
- 3
- 4
7. What is an example of polymorphism?
- Inner class
- Anonymous classes
- Method overloading
- Method overriding
8. Which of the following classes is used to perform basic console I/O?
- System
- SecurityManager
- Math
- Runtime
9. Which of the following are true? a)The Class class is the superclass of the Object class. b)The Object class is final. c)The Class class can be used to load other classes. d)The ClassLoader class can be used to load other classes.
- a&b
- c&b
- b&c
- c&d
10. Which of the following methods are methods of the Math class?
- absolute()
- log()
- cosine()
- sine( )