What are the operands of instanceof operator?

Answer Posted / shaik baji

"instanceof" is a java keyword and it comes under binary
operators.

For "instanaceof" operator
the first operand is : any instance or object
the second operand is : any class name

For Ex:
-------

class Demo
{}
class InstanceofDemo
{
public static void main(String[] args)
{
Demo obj = new Demo();
if (obj instanceof Demo)
System.out.println("yes");
else
System.out.println("no");
}
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is the purpose of "virtual"?

560


Can java hashmap have duplicate keys?

502


how do I create a runnable with inheritance? : Java thread

498


Can we write class inside a class in java?

540


Why vector class is used?

531






What are the Main functions of Java?

618


What is the requirement of thread in java?

608


What is final, finally, finalize?

586


What is class variable java?

574


Write a program in java to establish a connection between client and server?

498


Whats the difference between notify() and notifyall()?

560


What is the finalize method do?

592


What technique is carried out to find out if a particular string is empty?

557


What is type safety in java?

478


Explain working of call by reference function invoking.

581