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
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
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( )