instanceOf operator

What is difference between instanceOf operator and getclass()

Questions by Govind Gupta

Showing Answers 1 - 3 of 3 Answers

suraj20p

  • Oct 28th, 2011
 

instanceOf() is an operator used to find out whether an object is of instance of certain class or not

eg: String str=new String(); //here str is an object of String class
Sop(str.instanceOf(String));// returns true

int a[]=new int[10];

Sop(a.instanceOf(Object)); also returns true.bydefault all the array are the child of Object class


getClass() returns an object of Class type which is used to hold the .class file at the runtime itself

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions