Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1: Create a program with a superclass called Animal that has a method called animalSound(). Subclasses of Animals could be Cows, Cats, Dogs, Birds -

image text in transcribed
Q1: Create a program with a superclass called Animal that has a method called animalSound(). Subclasses of Animals could be Cows, Cats, Dogs, Birds - And they also have their own implementation of an animal sound (the cow moo's, the cat meows, etc.): Q2: Define the subclass and the super class in the following code, and write the expected output. class Vehicle protected String brand - "Ford"; // Vehicle attribute public void honkl) { // Vehicle method System.out.println("Tuut, tuut!"); 1 } class Car extends Vehicle private String modelName - "Mustang"; // Car attribute public static void main(String[] args) { // Create a myCar object Car myCar - new Car(); // Call the honk() method (from the Vehicle class) on the myCarobject TyCarbonk); // Display the value of the brand attribute (from the Vehicle class) and the value of the model Name from the Car class System.out.println(myCar brand + + myCar.modelName)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What are two of the main provisions of FLSA?

Answered: 1 week ago

Question

What is the growth rate of GDP per capita?

Answered: 1 week ago