1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Kisachek [45]
3 years ago
6

a) Write out an abstract class to represent a ball. Include data fields to store the weight of the ball as a double value and th

e color of the ball as a String. Include a no-arg constructor as well as a two-arg constructor to set these two fields. Declare an abstract method, howToPlay(), which is to describe how the ball is used by printing this description to the command line.
Computers and Technology
2 answers:
guapka [62]3 years ago
7 0

Answer:

Check the explanation

Explanation:

//Ball.java

public abstract class Ball {

   double value;

   String color;

   public Ball() {

   }

   public Ball(double value, String color) {

       this.value = value;

       this.color = color;

   }

   public abstract void howToPlay();

}

////////////////////////////////////////////

//SoccerBall.java

public class SoccerBall extends Ball {

   public void howToPlay() {

       System.out.println("Description to how to play soccer ball");

   }

}

Lyrx [107]3 years ago
3 0

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();

}

}

You might be interested in
What is the Microsoft excel window where you work on. And it composed of three worksheet?​
antoniya [11.8K]

Answer:

work book

Explanation:

A work book is a book in MS excel which contains work sheet

4 0
2 years ago
To enforce the concept of separating class definition from its function implementations, where should the function implementatio
zzz [600]
D(in a .c file ) because that is where it should be placed :)
4 0
2 years ago
Which part of the brain controls the movement of muscles​
Mekhanik [1.2K]

Answer:

PLEASE MARK AS BRAINLIEST

Explanation:

Cerebellum

Cerebellum. The cerebellum (back of brain) is located at the back of the head. Its function is to coordinate voluntary muscle movements and to maintain posture, balance, and equilibrium.

7 0
2 years ago
must understand both art and engineering. a. industrial designer b. environmental designer c. interior designer d. graphic desig
enot [183]
It's d. Graphic designer because they design things on the computer with code
7 0
3 years ago
When you are given a set of tables and asked to create a database to store their data, the first step is to ________?
Vlad1618 [11]
Scan   the tables  to make a digital copy of them
6 0
3 years ago
Other questions:
  • A drivers touches a cars steering wheel on a hot day which term refers to the way heat is transferredd to the drivers hand
    6·2 answers
  • The Apple II is an IBM-compatible PC "clone".<br> True?<br> False?
    10·1 answer
  • A network using multiple cell towers falls under which type of network?
    13·1 answer
  • *Please* read before answering.
    14·1 answer
  • Which of the following should you NOT do when using CSS3 properties to create text columns for an article element? a. make the c
    12·2 answers
  • Which type of market are you in if your firm, along with three other firms, controls 95% of the total music industry?
    13·1 answer
  • Issues with paper based records include a. time spent re-keying data, searching for paper copies, and filing. b. storage volume
    9·1 answer
  • How do you get banned? By getting reported? Or do admins watch whats posted?
    9·1 answer
  • Cash cows are always in
    7·1 answer
  • Add me on Fortnite. Epic is smashman892. *Ik it sux but it's an old account* Comment ur epic
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!