Showing posts with label interview. Show all posts
Showing posts with label interview. Show all posts

Monday, 24 November 2014

Java Interview Questions

Q1. How can you get to know that whether one object belongs to a particular class ?

Ans : using instanceof

The instanceof operator tests whether an object has in its prototype chain theprototype property of a constructor.

Eg :
We have a class test with a object
Test t1= new Test();
And another class Testing t2 = new Test();
If we have to find that whether t2 belong to Test class or not we will use

System.out.println(t2 instanceof Testing); //print true
      System.out.println(t2 instanceof Test); //printfalse

Java Collections Interview Questions
Read More »