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
Name the character encoding standard that enables up to 128 different commonly used characters,
Lelechka [254]

Answer:

ASCII character set.

Explanation:

ASCII is an acronym for American Standard Code for Information Interchange and it was developed from a telegraph code. It is typically a character encoding standard that comprises of seven-bit (7-bit) set of codes.

ASCII character set is the character encoding standard that enables up to 128 different commonly used characters, numbers and symbols to be used in electronic communication systems. The ASCII character set is only used for encoding English language and it comprises of both the lower case and upper case letters of the 26 alphabets, number 0 to 9 and symbols.

8 0
3 years ago
The first mechanical computer design in by Charles Babbage was Called​
White raven [17]

Answer:

<h2>Analytical Engine</h2>

Explanation:

Analytical Engine, generally considered the first computer, designed and partly built by the English inventor Charles Babbage in the 19th century (he worked on it until his death in 1871).

7 0
3 years ago
Read 2 more answers
Write a program whose input is two integers. Output the first integer and subsequent increments of 5 as long as the value is les
adell [148]

Answer:

Following are the code to the given question:

For code 1:

start = int(input())#defining a start variable that takes input from the user end

end = int(input())#defining a end variable that takes input from the user end

if start > end:#use if that checks start value greater than end value

   print("Second integer can't be less than the first.")#print message

else:#defining else block

   while start <= end:#defining a while loop that checks start value less than equal to end value

       print(start, end=' ')#print input value

       start += 5#incrementing the start value by 5

   print()#use print for space

For code 2:

while True:#defining a while loop that runs when its true

   data = input()#defining a data variable that inputs values

   if data == 'Done' or data == 'done' or data == 'd':#defining if block that checks data value

       break#use break keyword

   rev = ''#defining a string variable rev

   for ch in data:#defining a for loop that adds value in string variable  

       rev = ch + rev#adding value in rev variable

   print(rev)#print rev value

Explanation:

In the first code two-variable "first and end" is declared that takes input from the user end. After inputting the value if a block is used that checks start value greater than end value and use the print method that prints message.

In the else block a while loop is declared that checks start value less than equal to end value and inside the loop it prints input value and increments the start value by 5.

In the second code, a while loop runs when it's true and defines a data variable that inputs values. In the if block is used that checks data value and use break keyword.

In the next step, "rev" as a string variable is declared that uses the for loop that adds value in its variable and prints its values.

3 0
3 years ago
MATH PLZ HELP ITS DUE IN 4 MINUTES​
zheka24 [161]

Answer:

2

Explanation:

8 0
3 years ago
Read 2 more answers
What kind of information can be found in a ROM:
tester [92]
The answer is C, ROM often stores the basic instructions a computer needs when powering on, part if the BIOS.
3 0
3 years ago
Other questions:
  • Explain how to implement two stacks in one array A[1..n] in such a way that neither stack overflows unless the total number elem
    7·1 answer
  • GUI allows users to communicate with a device and see what they are doing onscreen.
    9·1 answer
  • Which is the biggest known issue specific to satellite Internet connections?
    13·2 answers
  • What is a screen tip
    6·1 answer
  • The game begins with the player having 20 POINTS
    11·1 answer
  • Select the two statements below that are true. Press on the info button for
    13·1 answer
  • How long does it take to send a 8 MiB file from Host A to Host B over a circuit-switched network, assuming: Total link transmiss
    11·1 answer
  • Classify the various scenarios in a web development team that is creating a website for a client according to the priority level
    9·1 answer
  • An acceptable website design is one that meets
    14·2 answers
  • Describe your WGU program, including two specific requirements that this degree has for completion.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!