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 plz give mi full and right answer
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();
}
}
Please mark me as the brainliest.
Similar questions
English,
1 month ago
Computer Science,
3 months ago
Math,
10 months ago
Physics,
10 months ago
Math,
10 months ago