From 975a727e1989ed4de895b5b61af584e58644c6eb Mon Sep 17 00:00:00 2001 From: Pretam Chandra Date: Tue, 26 Oct 2021 19:15:56 +0530 Subject: [PATCH] Implementation of Hybrid Inheritance --- .../Misc/HierarchialInheritance.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Program's_Contributed_By_Contributors/Java_Programs/Misc/HierarchialInheritance.java diff --git a/Program's_Contributed_By_Contributors/Java_Programs/Misc/HierarchialInheritance.java b/Program's_Contributed_By_Contributors/Java_Programs/Misc/HierarchialInheritance.java new file mode 100644 index 0000000000..dfaa537617 --- /dev/null +++ b/Program's_Contributed_By_Contributors/Java_Programs/Misc/HierarchialInheritance.java @@ -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); + } +} \ No newline at end of file