Which of the following is a valid Java keyword (reserved word) recognized by the Java compiler?
-
Ainterface
-
Bstring
-
CFloat
-
Dunsigned
-
ENone of these
Answer
Correct Answer: interface
Explanation
Introduction / Context:Java reserves certain words as keywords so they cannot be used as identifiers. Remembering these is important for reading code and avoiding compilation errors.
Given Data / Assumptions:
- The options mix actual keywords with common identifiers or non-Java concepts.
- Java is case-sensitive; keyword case matters.
Concept / Approach:Keywords include class, interface, native, synchronized, etc. Non-keywords like string (lowercase) or Float (type name in java.lang) are not reserved. Java has no unsigned keyword for primitive declarations.
Step-by-Step Solution:
interface → Valid keyword defining a contract type.string → Not a keyword; Java’s type is String (class), not a reserved word.Float → Class name (java.lang.Float), not a keyword.unsigned → Not supported in Java primitives.Verification / Alternative check:Try using each as an identifier; only non-keywords will compile as variable names.
Why Other Options Are Wrong:They are either class names or non-existent in Java’s keyword list.
Common Pitfalls:Confusing class names with keywords; Java keyword set is fixed and case-sensitive.
Final Answer:interface