Correct option is D
In Java, the instanceof operator is used to test whether an object is an instance of a particular class or subclass. This operator is built into the Java language and cannot be overloaded. Operator overloading is not supported in Java for most operators except for the + operator, which is implicitly overloaded for string concatenation.
Important Key Points:
1. Java does not allow explicit operator overloading, except for the + operator used for string concatenation.
2. The instanceof operator is specifically used for runtime type checking and is inherently part of the Java language syntax.
3. Operators like = (assignment) and == (comparison) also cannot be explicitly overloaded in Java.
Knowledge Booster:
·
Operator Overloading in C++ vs. Java: In C++, almost all operators can be overloaded, whereas Java restricts this for simplicity and code readability.
·
String Concatenation: The + operator is overloaded for concatenating strings in Java (e.g., "Hello " + "World" results in "Hello World").
·
Other Non-Overloadable Operators: Logical operators (&&, ||), relational operators (>, <), and the instanceof operator are non-overloadable in Java.