Java MCQ Questions and Answers – Test Your Knowledge
Are you preparing for a Java certification or interview? Testing your knowledge with java mcq questions and answers is a great way to assess your understanding of core concepts. Below are some commonly asked multiple-choice questions along with explanations to help you strengthen your Java skills.
1. What is the output of the following code?
java
Copy
public class Main {
public static void main(String[] args) {
System.out.println(10 + 20 + "Java");
}
}
Options:
A) 30Java
B) 1020Java
C) Compilation Error
D) Runtime Error
Answer: A) 30Java
Explanation: The + operator performs addition first (10 + 20 = 30) and then concatenates with "Java".
2. Which keyword is used to prevent method overriding in Java?
Options:
A) static
B) final
C) abstract
D) private
Answer: B) final
Explanation: The final keyword prevents a method from being overridden in subclasses.
3. What does JVM stand for?
Options:
A) Java Virtual Machine
B) Java Variable Method
C) JRE Virtual Memory
D) Just Virtual Machine
Answer: A) Java Virtual Machine
Explanation: JVM is the runtime engine that executes Java bytecode.
4. Which collection class is synchronized by default?
Options:
A) ArrayList
B) HashSet
C) Vector
D) LinkedList
Answer: C) Vector
Explanation: Vector is thread-safe and synchronized, unlike other collections.
5. What is the default value of a boolean in Java?
Options:
A) true
B) false
C) null
D) 0
Answer: B) false
Explanation: Uninitialized boolean variables default to false.
Practicing Java MCQ questions and answers helps reinforce key concepts. Have more questions or need clarification? Drop them in the comments below!
回答
まだコメントがありません
新規登録してログインすると質問にコメントがつけられます