Learn JAVA MCQs
Prepare JAVA MCQs (Multiple choice Questions) for exam and job interviews.
What is the output of System.out.println("Java".toLowerCase());?
1) java
2) Java
3) JAVA
4) None of the above
Answer : java
Which of the following statements is used to declare a method that does not return any value?
1) public void methodName()
2) public methodName()
3) methodName(): void
4) None of the above
Answer : public void methodName()
What is the output of System.out.println("Java".length());?
1) 4
2) 5
3) 6
4) None of the above
Answer : 4
Which of the following is true about abstract methods in Java?
1) They have no body.
2) They must be defined in abstract classes.
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2
What is the output of System.out.println(4 << 1);?
1) 2
2) 4
3) 8
4) None of the above
Answer : 8
Which of the following keywords is used for exception handling in Java?
1) catch
2) throw
3) try
4) All of the above
Answer : All of the above
What is the output of System.out.println(5 - 10);?
1) -5
2) 5
3) Error
4) None of the above
Answer : -5
Which of the following can be used to create an immutable class in Java?
1) Using final keyword
2) Using private constructors
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2
What is the output of System.out.println(Math.sqrt(16));?
1) 4
2) 16
3) Error
4) None of the above
Answer : 4
Which of the following is a correct way to create a string in Java?
1) String str = new String();
2) String str = "Hello";
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2