Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

8. Based on the following definition of a class named Vehicle, answer Alt of the following questions: package my,codes. Vehicle; public class Vehicle { private

image text in transcribed

image text in transcribed

image text in transcribed

8. Based on the following definition of a class named Vehicle, answer Alt of the following questions: package my,codes. Vehicle; public class Vehicle \{ private String model; public vehicle (String mode1) \{ this, model model; void sound() \{ System.out.println("Ny Sound is:"); | a) The following is the definition of a child class of vehicle named Bicycle. However, the constructor of Bicycle class is missing. Write the complete definition of the Bicycle constructor. (3 marks) b) The following is the definition of another child class of vehicle named car. The constructor of the Car class is not shown (assume that it has been correctly defined). However, the car class cannot be compiled because it has a syntax error. Identify the statement that produces the error and then briefly explain about the error. (3 marks) c) Suppose we are going to create an array, named myLiat that can store references to both Car and Bicycle objects. Write the correct lava statement to declare and create the array myList with size 10. (1 mark) d) A Car object is created and assigned to the element at index 1 in the array myList. Write the correct Java statement(s) to invoke the diaplay () method of this Car object. (3 marks) e) The definition of an interface named Flyable is given as follows: Suppose we want to define a Flyingcar class that inherits all properties from the Car class as well as implements all methods in the Flyable interface. Write the complete header of the rlyable class definition. (2 marks) 8. Based on the following definition of a class named Vehicle, answer Alt of the following questions: package my,codes. Vehicle; public class Vehicle \{ private String model; public vehicle (String mode1) \{ this, model model; void sound() \{ System.out.println("Ny Sound is:"); | a) The following is the definition of a child class of vehicle named Bicycle. However, the constructor of Bicycle class is missing. Write the complete definition of the Bicycle constructor. (3 marks) b) The following is the definition of another child class of vehicle named car. The constructor of the Car class is not shown (assume that it has been correctly defined). However, the car class cannot be compiled because it has a syntax error. Identify the statement that produces the error and then briefly explain about the error. (3 marks) c) Suppose we are going to create an array, named myLiat that can store references to both Car and Bicycle objects. Write the correct lava statement to declare and create the array myList with size 10. (1 mark) d) A Car object is created and assigned to the element at index 1 in the array myList. Write the correct Java statement(s) to invoke the diaplay () method of this Car object. (3 marks) e) The definition of an interface named Flyable is given as follows: Suppose we want to define a Flyingcar class that inherits all properties from the Car class as well as implements all methods in the Flyable interface. Write the complete header of the rlyable class definition. (2 marks)

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_2

Step: 3

blur-text-image_3

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

Deductive And Object Oriented Databases Second International Conference Dood 91 Munich Germany December 18 1991 Proceedings Lncs 566

Authors: Claude Delobel ,Michael Kifer ,Yoshifumi Masunaga

1st Edition

3540550151, 978-3540550150

More Books

Students also viewed these Databases questions