Question discussion

In Java, the instanceof operator is used to

2555Medium DSSSB TGT Computer Science 0 replies

In Java, the instanceof operator is used to

  • Atest whether an object is an instance of a particular class or interface, and it returns a boolean value
  • Bcreate a new instance of a class
  • Ccompare the contents of two strings
  • Dfind the number of instances of a class that exist in memory
Correct answer: A

Explanation

The expression obj instanceof ClassName evaluates to true if obj refers to an object of that class (or of a subclass or implementing class) and to false otherwise.

Discussion 0

Nobody has replied yet. Start the discussion!