Java - Language Fundamentals Questions and Answers
Practice ModeShowing 10 of 39 questions
Q21
What is the default value of a boolean variable in Java?
Answer: Option B
Explanation: The default value of a boolean variable is false.
Q22
Which of the following is a valid main method declaration?
Answer: Option B
Explanation: This is the correct syntax and order for the main method.
Q23
Which keyword is used to declare a constant in Java?
Answer: Option C
Explanation: The final keyword prevents modification of a variable.
Q24
Which of the following is a valid Java comment?
Answer: Option C
Explanation: // is used for single-line comments in Java.
Q25
What is the default value of an object reference variable?
Answer: Option C
Explanation: Reference variables default to null.
Q26
Which keyword is used to create an object in Java?
Answer: Option B
Explanation: The new keyword allocates memory for an object.
Q27
Which operator is used for equality comparison in Java?
Answer: Option B
Explanation: == compares primitive values for equality.
Q28
Which of the following is NOT an access modifier in Java?
Answer: Option D
Explanation: Java does not support the internal access modifier.
Q29
Which package is automatically imported in every Java program?
Answer: Option C
Explanation: The java.lang package is imported by default.
Q30
Which keyword is used for inheritance in Java?
Answer: Option C
Explanation: The extends keyword allows a class to inherit another class.