Question 1/12: This code demonstrates valid class inheritance – true or false?
Hint: Click to show.
class Vehicle {
var wheels: Int
init(wheels: Int) {
self.wheels = wheels
}
}
class Truck: Vehicle {
var goodsCapacity: Int
init(wheels: Int, goodsCapacity: Int) {
self.goodsCapacity = goodsCapacity
super.init()
}
}
Link copied to your pasteboard.