Try this:
MyObject obj = new MyObject();
if(obj instanceof MyObject){System.out.println("true");} //true
Because of inheritance this is valid for interfaces, too:
class Animal {}
class Dog extends Animal {}
Dog obj = new Dog();
Animal animal = new Dog();
if(obj instanceof Animal){System.out.println("true");} //true
if(animal instanceof Animal){System.out.println("true");} //true
if(animal instanceof Dog){System.out.println("true");} //true
For further reading on instanceof: http://mindprod.com/jgloss/instanceof.html