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 difference between path and classpath in java?

720


Variables used in a switch statement can be used with which datatypes?

751


Why java does not support pointers?

800


Explain the polymorphism principle?

795


State some advantages of java?

1002


Can we have multiple classes in single file ?

834


What is an infinite loop in java? Explain with an example.

808


How do you check if two strings are equal in java?

817


What is an example of a constant variable?

813


What does you mean in math?

799


What is a buffer in computer?

734


Can we use switch statement with strings?

821


What is difference between null and void?

744


What is the flag in java?

804


What are different ways of object creation in java ?

792