0% found this document useful (0 votes)
19 views2 pages

HybridInheritence

Uploaded by

Neha Vengurlekar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

HybridInheritence

Uploaded by

Neha Vengurlekar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

interface Test {

int ATTENDANCE = 0;
int FMARKS = 0;

int getTotalWeightage();
}

class Student {
private String name;
private int rollNo;

public Student(String name, int rollNo) {


this.name = name;
this.rollNo = rollNo;
}

public void displayInfo() {


System.out.println("Name: " + name);
System.out.println("Roll No: " + rollNo);
}
}

class TestImpl extends Student implements Test {


private int attendance;
private int finalMarks;

public TestImpl(String name, int rollNo, int attendance, int finalMarks) {


super(name, rollNo);
this.attendance = attendance;
this.finalMarks = finalMarks;
}

@Override
public int getTotalWeightage() {
return (attendance + finalMarks) / 2;
}

public void displayTestInfo() {


System.out.println("Attendance: " + attendance);
System.out.println("Final Marks: " + finalMarks);
}
}

class Result extends TestImpl {


private int totalWeightage;

public Result(String name, int rollNo, int attendance, int finalMarks) {


super(name, rollNo, attendance, finalMarks);
this.totalWeightage = getTotalWeightage();
}

public void displayResult() {


super.displayInfo();
super.displayTestInfo();
System.out.println("Total Weightage (TW): " + totalWeightage);
}
}

public class HybridInheritence {


public static void main(String[] args) {
Result studentResult = new Result("John Doe", 101, 80, 85);
studentResult.displayResult();
}
}

You might also like