Java MCQ Question and Answer

Java MCQ Question and Answer
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
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
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
4. What is the value of a[3] as the result of the following array declaration?
  • 1
  • 2
  • 3
  • 4
Show Answer
5. Which of the following are primitive types?
  • byte
  • String
  • integer
  • Float
Show Answer
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
7. What is an example of polymorphism?
  • Inner class
  • Anonymous classes
  • Method overloading
  • Method overriding
Show Answer
8. Which of the following classes is used to perform basic console I/O?
  • System
  • SecurityManager
  • Math
  • Runtime
Show Answer
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
10. Which of the following methods are methods of the Math class?
  • absolute()
  • log()
  • cosine()
  • sine( )
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test