Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of Hybrid Inheritance #1220

Merged
merged 1 commit into from
Oct 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
class Teacher
{
int com;
void taught(int a,int b)
{
System.out.println("Age of the teacher = " + a);
com = b;
}
void show()
{
System.out.println("Syllabus Completed:- " + com + "%\n");
}
}

class Student1 extends Teacher
{
void report1(int s, int m)
{
show();
System.out.println("\n1st STUDENT\n");
System.out.println("Syllabus Completed:- " + com + "%");
System.out.println("Marks obtained:- " + m);
}
}
class Student2 extends Teacher
{
void report2(int s, int m)
{
System.out.println("\n2nd STUDENT\n");
System.out.println("Syllabus Completed:- " + s + "%");
System.out.println("Marks obtained:- " + m);
}
}

class HierarchialInheritance
{
public static void main(String args[])
{
Student1 s1 = new Student1();
Student2 s2 = new Student2();
s1.taught(60,98);
s1.report1(90,75);
s2.report2(70,68);
}
}