Java MCQ Questions and Answers

Take Exam

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
Show Answer Report

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
Show Answer Report

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
Show Answer Report

4. What is the value of a[3] as the result of the following array declaration?

  • 1
  • 2
  • 3
  • 4
Show Answer Report

5. Which of the following are primitive types?

  • byte
  • String
  • integer
  • Float
Show Answer Report

6. What is the range of the char type?

  • 0 to 216
  • 0 to 215
  • 0 to 216-1
  • 0 to 215-1
Show Answer Report

7. What is an example of polymorphism?

  • Inner class
  • Anonymous classes
  • Method overloading
  • Method overriding
Show Answer Report

8. Which of the following classes is used to perform basic console I/O?

  • System
  • SecurityManager
  • Math
  • Runtime
Show Answer Report

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
Show Answer Report

10. Which of the following methods are methods of the Math class?

  • absolute()
  • log()
  • cosine()
  • sine( )
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test