Java MCQ Questions and Answers

Practice Mode
Showing 10 of 22 questions
Q1
What output is displayed as the result of executing the following statement? System.out.println("// Looks like a comment.");
  • A // Looks like a comment
  • B The statement results in a compilation error
  • C Looks like a comment
  • D No output is displayed
Answer: Option A
Q2
In order for a source code file, containing the public class Test, to successfully compile, which of the following must be true?
  • A It must have a package statement
  • B It must be named Test.java
  • C It must import java.lang
  • D It must declare a public class named Test
Answer: Option B
Q3
Which of the following declare an array of string objects? a)String[ ] s; b) String [ ]s: c)String[ s]: d) String s[ ]:
  • A a& b
  • B a,b& c
  • C c&a
  • D a,b& d
Answer: Option D
Q4
What is the value of a[3] as the result of the following array declaration?
  • A 1
  • B 2
  • C 3
  • D 4
Answer: Option D
Q5
Which of the following are primitive types?
  • A byte
  • B String
  • C integer
  • D Float
Answer: Option A
Q6
What is the range of the char type?
  • A 0 to 216
  • B 0 to 215
  • C 0 to 216-1
  • D 0 to 215-1
Answer: Option D
Q7
What is an example of polymorphism?
  • A Inner class
  • B Anonymous classes
  • C Method overloading
  • D Method overriding
Answer: Option C
Q8
Which of the following classes is used to perform basic console I/O?
  • A System
  • B SecurityManager
  • C Math
  • D Runtime
Answer: Option A
Q9
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 a&b
  • B c&b
  • C b&c
  • D c&d
Answer: Option D
Q10
Which of the following methods are methods of the Math class?
  • A absolute()
  • B log()
  • C cosine()
  • D sine( )
Answer: Option B
Questions and Answers for Competitive Exams Various Entrance Test