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
There are local administrators for each of the departments, excluding the IT. These local administrators will use the local admi
torisob [31]

Answer:

Listed below are the few ways Linux Server can be secured

1. Group policies: This is a way to ensure security by applying group policies and permissions both on the group level and the files level. Through proper permission configuration we can easily restrict other users from accessing those files and directories.

2. Implementation of the firewall: Implementing firewall in each of the Linux server will definitely help in securing your machine from outside threats. Iptables will help in filtering the network traffic that are entering into the system and even going out of the system.

3.Enabling SELINUX: Enabling SELINUX is another way to secure your system especially a Linux Server. Selinux is a powerful security that checks and allows applications to run into the system. It won't allow any untrusted application to run into the system.

6 0
3 years ago
Among object-oriented languages, one feature that varies considerably is whether the language allows multiple inheritance. C++ d
Amiraneli [1.4K]

Multiple inheritance causes Diamond problem which happens when:

Class A is parent of class B and C

Now when class D will be inherited from both Class B and C it will have all the members of class A and B which if same will confuse the compiler to import which one?

C++ solves it by using virtual keyword with them and thus telling the compiler which one to inherit.

Java has introduced the interface concept rather then allowing multiple inheritance.

4 0
3 years ago
Write a program that declares and initializes a variable representing the weight in milligrams from the keyboard. The program di
Burka [1]

Answer:

weight = int(input("Enter weight in milligrams: "))

kilograms = int(weight / 1000000)

grams = int((weight - (kilograms * 1000000)) / 1000)

milligrams = weight - ((kilograms * 1000000) + (grams * 1000))

print("{} milligrams are equivalent to {} kilogram(s), {} gram(s), and {} milligram(s)".format(weight, kilograms, grams, milligrams))

Explanation:

*The code is in Python.

Ask the user to enter the weight and set it to the variable weight

Calculate the kilograms, divide the weight by 1000000 and cast the result to the int (If the weight is 1050042, kilograms would be 1050042/1000000 = 1)

Calculate the grams, subtract the kilograms from the weight, divide it by 1000 and cast the result to the int (If the weight is 1050042, grams would be int((1050042 - (1 * 1000000)) / 1000) = 50)

Calculate the milligrams, subtract the kilograms and grams from the weight (If the weight is 1050042, milligrams would be 1050042 - ((1 * 1000000) + (50 * 1000)) = 42)

Print the weight, kilograms, grams, and milligrams in the required format

3 0
3 years ago
The option to add the date and time to a document is located in the
Tomtit [17]

Answer:

The option to add the date and time to a document is located in the

text grouping on the Insert tab.

Explanation:

8 0
3 years ago
Read 2 more answers
A class car and its subclass bmw each have a method run(), which was written by the developer as part of the class definition. i
krok68 [10]

The answer is : the run() method defined in BMW will be called.

run() BMW

5 0
3 years ago
Other questions:
  • What are some consequences of internet addiction​
    9·1 answer
  • In a system using the fixed partitions memory allocation scheme, given the following situation (and using a decimal form): After
    9·1 answer
  • What is the full form of icimod?
    6·1 answer
  • What is something that can be done to help stop teen teen crashes
    8·1 answer
  • Name two materials that we can burn in order to get energy from biomass
    9·1 answer
  • The I/O modules take care of data movement between main memory and a particular device interface.A. TrueB. False
    9·1 answer
  • HELP!!!
    15·2 answers
  • You are trying to sell a new product to a store owner. Which method of presentation
    10·1 answer
  • Please Answer ASAP!!
    15·1 answer
  • Create a file using any word processing program or text editor. Write an application that displays the files, name, containing f
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!