Java program to understand basic concept of single level inheritance

Single level inheritance

This program shows the concept of single level inheritance.Their are two classes in this program one is “scan” and second is “derived”.Derived class has both the class property i.e “scan” as well as its own property.We have created a object “d1” of class ‘derived’ and called the functions of both class using same object “d1”.

import java.util.*;
class scan
{
	 public void base()
	 {
 System.out.println("This is base class");
}
}
class derived extends scan
{
    public void run()
   {
     System.out.println("This is derived class");
   }
 
 public static void main(String arg[])
{
 derived d1=new derived();
 d1.base();
 d1.run();
}

}

Output of single level inheritance

single level inheritance

Leave a Reply

Your email address will not be published. Required fields are marked *