Answer:
See explaination
Explanation:
Code
abstract class Ball
{
double weight;
String color;
Ball()
{
this.weight=0;
this.color=" ";
System.out.println("Abstract class constructor");
}
Ball(double weight,String color)
{
this.weight=weight;
this.color=color;
System.out.println("Parameterized constructor of Abstract class with weight = "+weight+" color = "+color);
}
public abstract void howToPlay();
}
public class Baseball extends Ball {
int no;
String name;
int bat,hi ts;
Baseball() {
super(20,"red");
System.out.println("BaseBall class Constructor");
}
Baseball(int no,String name,int bat,int hi ts)
{
this.no=no;
this.name=name;
this.bat=bat;
this.hi ts=hi ts;
}
public void howToPlay()
{
System.out.println("How to play method weight = "+weight+ " color = "+color);
}
public void display()
{
System.out.println("Player no: "+no+" name = "+name+" numberAtbat = "+bat+" hi ts = "+hit s);
}
public static void main(String[] args) {
Baseball ob j = new Baseball();
Baseball ob j1 = new Baseball(1,"abc",1,3);
ob j.howToPlay();
ob j1.display();
}
}