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]
4 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]4 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]4 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
Using ______, a smartphone can connect to an automobile audio/control system
lys-0071 [83]
<span>Using bluetooth, a smartphone can connect to an automobile audio/control system</span>
5 0
3 years ago
Technician A says a modern automobile has more than 1 mile of wiring. Technician B says there could be more than 1,000 individua
FinnZ [79.3K]
Both because if you put all of the wires from end to end there is more then one mile of wiring 
7 0
3 years ago
Bryan knows that it takes him fifteen minutes to drive to work, or twenty minutes if every traffic light is red on the way there
lisabon 2012 [21]
<span>The answer is "punctuality"; Being on time is respectful to your co-workers and to the organization and is a good workplace habit. It is a sign to others of your reliability, that they can depend on you. Their are many positive that come from is habit, such as clients knowing they can reach someone, or morning meetings that are more productive, or colleagues who are are more efficient not having to cover for you until you arrive.</span>
5 0
4 years ago
Read 2 more answers
The ........ tag is used to create a link to another document​
Free_Kalibri [48]

Answer:

The "a" tag or <a></a> and its "h<u>r</u>ef" attribute <a href="#"></a>

Explanation:

In html there is only one way to create a link to an external source or a bookmark. The tag is created using the element <a>.

The attribute "href" is then added to describe the link of where it is to point to.

Example:

<a href="google.com">Go to Google</a>

While the text in between the tag describes what the link is about.

7 0
3 years ago
When using bits to represent fractions of a number, can you create all possible fractions? Why or why not?
seropon [69]

Explanation:

Using this technique a number is represented in bits by three parts: sign, exponent, and fraction. This is similar to scientific notation used to represent large or small numbers (e.g. ). The sign is negative, the exponent is 8 and the fraction is 0.35.

8 0
3 years ago
Other questions:
  • On most computers, the default font size in word is ____. 8 11 14 16
    8·2 answers
  • Is downloading like installing?
    13·1 answer
  • Examine the following declarations and definitions for the array-based implementations for the Stack and Queue ADTs. Assume that
    14·1 answer
  • Why might you complete a 1040 instead of a <br> 1040ez
    11·2 answers
  • Good ways to increase sales on phone accesories?
    10·2 answers
  • my I phone is in recovery mode and when I connect to my PC the I device is not connected to iTunes although i have the latest ve
    7·2 answers
  • How do I use brainly.<br> What is brainliest.<br> And what is the rating thing about
    6·2 answers
  • How do u type please help
    11·2 answers
  • enter formula that uses the IF function to test whether the number of years of experience (cell M5) is greater than or equal to
    9·1 answer
  • We initialize the parameters to all zero values and run the linear perceptron algorithm through these points in a particular ord
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!