Write a program to create a class Student, class Test inherits
class Students. Define an interface Sports, class Ressults
implements all interfaces. Create a main class Hybrid an object of
Results to invoke all the required methods and display student
result class.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
47 views3 pages
Hybrid - Inheritance in Java
Write a program to create a class Student, class Test inherits
class Students. Define an interface Sports, class Ressults
implements all interfaces. Create a main class Hybrid an object of
Results to invoke all the required methods and display student
result class.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3
EXP11: Write a program to create a class Student, class Test inherits
class Students. Define an interface Sports, class Ressults
implements all interfaces. Create a main class Hybrid an object of Results to invoke all the required methods and display student result class. Source code: import java.util.*; class Student{ String name; int rollNo;
public void details(){
Scanner sc = new Scanner(System.in); System.out.print("Enter Name: "); name = sc.nextLine();
System.out.print("Enter Roll No: ");
rollNo = sc.nextInt(); } }
class Test extends Student {
float s1,s2; public void Test(){ Scanner sc = new Scanner(System.in);
float TotalCredits; public float getTotalCredits() { return TotalCredits = ( s1 + s2 ) / 2 + sportsCredits; } } public class TotalCredits { public static void main(String[] args) { Scanner s = new Scanner(System.in); Results results = new Results(); results.details(); results.Test();
System.out.println("\nDisplaying Results: ");
System.out.println("Student Name: " + results.name); System.out.println("Student Roll no: " + results.rollNo); System.out.println("First Year CGPA(average of both sem + sports credits): " + results.getTotalCredits());