Java Programming
About Lesson

If a class is derived from one parent class, then it is known as Single or single level inheritance. In this case only one parent and one child class can be seen.

 

//Example showing how single inheritance can be created
class student
{
float marks=98.5f;
}

class employee extends student
{
int sal=50000;
}

public class SingleInheritanceEg {

public static void main(String[] args) {
employee e1=new employee();

System.out.println(“Marks secured: “+e1.marks);
System.out.println(“Salary: “+e1.sal);

}

}

You cannot copy content of this page