title: Overriding the same function for different sub classes is polymorphism?
body: <p>I read somewhere that, overriding is the means by which you get polymorphism. Polymorphism is the ability for an object to vary behavior based on its type.</p>
  
  <p>Now can i just say that when different subclasses override the member of a parent class then it gives me polymorphism?</p>
  
  <p>Also </p>
  
  <pre><code>class A
  {
  public void hello()
  {
  printf("in A");
  }
  }
  
  class B extends A
  {
  public void hello()
  {
  printf("in B");
  }
  }
  
  class C extends A
  {
  public void hello()
  {
  printf("in C);
  }
  }
  </code></pre>
  
  <p>Now if i do</p>
  
  <pre><code>B b=new B();
  C c=new C();
  A a1=b;
  A a2=c;
  a1.hello();
  a2.hello();
  </code></pre>
  
  <p>now will a1 use all the members of b those are inherited from A and hence print <code>in B</code>; and similarly for a2?</p>