Thursday, 6 June 2013

Single level Inhertance

In single level inheritance there is one base class and one child class that inherits the  features of the base class. The child class inherits the child class using the keyword"extends".
Syntax for single level inheritance is:
   class Child_class_name extends Base_class_name

Program for Single Level Inheritance

class My        //Base class
{
void input()
{
System.out.println("Class My");
}
}

class You extends My                       // class You inherits My class
{
void output()
{
System.out.print("Class You");
}
}

class Slevel
{
public static void main(String arg[])
{
You obj=new You();
obj.input();
obj.output();
}
}

No comments:

Post a Comment

full details in json
Proudly Powered by Blogger.
back to top