asked 165k views
0 votes
a java program to create a base class sports with a method called play().create subclasses:football,basketball and rugby​

1 Answer

3 votes

Final answer:

A Java program that creates a base class "Sports" with a method "play()" and creates subclasses for Football, Basketball, and Rugby.

Step-by-step explanation:

The question is asking for a Java program to create a base class called Sports with a method called play().

The program should also create subclasses for Football, Basketball, and Rugby.

Here is an example of how the program could be implemented:

class Sports {
public void play() {
System.out.println("Playing sports");
}
}

class Football extends Sports {
// additional methods and fields specific to football
}

class Basketball extends Sports {
// additional methods and fields specific to basketball
}

class Rugby extends Sports {
// additional methods and fields specific to rugby
}

In this example, the base class Sports has a method play() that simply prints "Playing sports". The subclasses Football, Basketball, and Rugby can inherit this method and add their own specific methods and fields.

answered
User Franz
by
7.6k points