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
In which decade did personal computers become commonplace in offices, schools, and some homes?
iren [92.7K]
The decade in which the personal computers became commonplace in offices, schools, and some homes were the 1980s. 
8 0
3 years ago
What wikileaks mean? what does that mean ''wiki'' and what does that mean '' leaks''?
guapka [62]
Wiki is short for Wikipedia and if someone on wiki leaks some personal information or something not to be released yet, that would be a wiki leak
8 0
4 years ago
Read 2 more answers
Nathan notices his computer system is slowing down when he tries to copy documents to it. He also gets a prompt that warns him t
vesna_86 [32]
You would replace the hard drive
3 0
3 years ago
The chemical symbol H represents which of the following elements?
scZoUnD [109]
The answer is D. Hydrogen
helium is He (just for extra knowledge)
4 0
3 years ago
Read 2 more answers
Linux is: Question 5 options: A) especially useful for processing numeric data. B) designed for specific machines and specific m
Reil [10]

Answer:

Option E. an example of open-source software.

Explanation:

Linux is an open source operating system which is very popular among software developers around the world. For example, web hosting are commonly done in a Linux server.  It is first release by Linus Torvalds in 1991. Source code of Linux can be reused, modified and redistributed without any cost by following the terms specified by GNU General Public License. Linux can also be distributed either for non-commercial or commercial purpose. The commercial distribution includes Red Hat and SUSE Linux Enterprise Server.

7 0
3 years ago
Other questions:
  • ____ is an object-oriented programming language from Sun Microsystems which allows small programs called applets to be embedded
    13·1 answer
  • For C programming language, what does it mean when you have an exclamation mark after an equal sign? ie:
    5·1 answer
  • Edhesive coding practice 3.4​
    12·1 answer
  • Using computers in place of paper to design components, products, and processes is referred to as ______.
    11·1 answer
  • Rose opens her software application and gets a message stating that she has only 16 more uses of the product available. Given th
    15·1 answer
  • The Gas-N-Clean Service Station sells gasoline and has a car wash. Fees for the car wash are $1.25 with a gasoline purchase of $
    6·1 answer
  • Select the correct answers
    9·1 answer
  • What does a class do?
    10·1 answer
  • String objects are modified with string slices true or false
    9·1 answer
  • Web résumés allow you to include extra graphics and images that you would not include in a traditional résumé. Please select the
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!