Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Java and what you know about inheritance: 1. Use proper encapsulation to write the following classes a. Create a Vehicle class that has two

Using Java and what you know about inheritance:

image text in transcribed

1. Use proper encapsulation to write the following classes a. Create a Vehicle class that has two instance variables: doors and mileage. Doors is an int and mileage is a double. payload instance variable that is an integer engine size variable that is a double b. Create a Truck class that inherits from Vehicle. A Truck class should have a c. Create a Pickup class that inherits from Truck. A Pickup class should have an d. Create a Trailer class that inherits from Truck. A Trailer class should have a String variable called name. 2. In each of the above classes, you must override the Object class toStringmethod that returns a String value. You should return a String that accurately represents the current Object. You should not duplicate code in these methods. 3. In a separate Driver class, you must do the following: Create a main method to test your classes. Create at least 1 Vehicle, Truck, Pickup and Trailer object. Make various calls to all of the methods to make sure your classes are implemented correctly. Be sure to print out each object utilizing the toString method

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

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899