hoa nguyen, 5.4
Question 2:
(3 marks) Write a class Car and a class SpecCar extending from Car (i.e. Car is a superclass and
SpecCar is a subclass) with the following information:
-color:String
-seat:int
Car
Where:
getColor():String- return color.
getSeat():int-return Seat.
2 of 2
+Car()
Paper No: 3
+Car(color:String, seat:int)
+getColor():String
+getSeat():int
+setColor(color:String):void

setColor(color:String):void - update color.

toString(): String-return the string of format:
color, seat
+toString():String
Zoom
- FUO
SpecCar
-model:String
+SpecCar()
+SpecCar(color:String, Seat:int, model:String)
+getModel():String
+toString():String
+ 100%
•
Where:
toString():String return the string of
format:
color, seat, model

getModel():String return model.
.setData():void - Remove the first letter
in the color string.
Close