write a program to implement single inheritance base class: student with roll no, name as data mambers derived class as sports with sports marks derived class as sports with sports masrks as data member read and display data for one student in java programs
Answers
Answered by
0
Answer:
class Student {
int roll;
String name;
Student(int roll, String name) {
this.roll = roll;
this.name = name;
}
}
class Sports extends Student {
int sportsMarks;
Sports(int roll, String name, int sportsMarks) {
super(roll, name);
this.sportsMarks = sportsMarks;
}
void display() {
System.out.println("Roll = " + roll);
System.out.println("Name = " + name);
System.out.println("Sports Marks = " + sportsMarks);
}
}
public class Main {
public static void main(String[] args) {
Sports s = new Sports(101, "Hitesh", 100);
s.display();
}
}
Explanation:
Please mark me as the brainliest.
Similar questions