title: Why can't I assign a derived class object to base class object in java?
body: <p>Here is the code:</p>
  
  <pre><code>class base
  {
      public void abc()
      {
          System.out.print("what's up dude");
      }
  }
  
  class derived
  {
      public void abc()
      {
          System.out.print("wad up ");
      }
  }
  
  public class superreftosub
  {
      public static void main(String args[])
      {
          base b=new base();
          derived d=new derived();
          base b=d;
          b.abc();
      }
  }
  </code></pre>