View RSS Feed

Java Object

Object-oriented programming in Java.

  1. The instanceof Keyword

    by , 04-26-2012 at 06:33 PM
    Instanceof operator can be used for determining that dog is an animal & Mammal is an animal.
    interface Animal{}
    Java Code:
    class Mammal implements Animal{}
    
    class Dog extends Mammal{
       public static void main(String args[]){
    
          Mammal m = new Mammal();
          Dog d = new Dog();
    
          System.out.println(m instanceof Animal);
          System.out.println(d instanceof Mammal);
          System.out.println(d instanceof
    ...