title: Is it possible to call subclasses' methods on a superclass object?
body: <p>Animal is a superclass of Dog 
  and Dog has a method called bark</p>
  
  <pre><code>public void bark()
  {
      System.out.println("woof");
  }
  </code></pre>
  
  <p>Consider the following:</p>
  
  <pre><code>Animal a = new Dog();
  if (a instanceof Dog){
      a.bark();
  }
  </code></pre>
  
  <p>What will happen?</p>
  
  <ol>
  <li>the assignment isn't allowed</li>
  <li>the call to bark is allowed and "woof" is printed at run time</li>
  <li>the call to bark is allowed but nothing is printed</li>
  <li>the call to bark causes a compile time error </li>
  <li>the call to bark results in a run time error </li>
  </ol>
  
  <p>I said 2 as we are checking if the object is a dog; as dog is the class with the bark method in it, if it is then we call it which will print out :s</p>
  
  <p>Is my understanding correct here?</p>