Quiz 7
Friday
With a piece of paper, write down your name and answers to the following questions.
In an inheritance relationship, what is the general class?
- subclass
- superclass
- slave class
- child class
What keyword refers to an object’s superclass?
super
base
this
extends
Which superclass members cannot be accessed by its subclasses?
public
protected
private
- All of the above can be accessed by the subclasses.
Is the following statement correct, and why?
A method in a subclass that has the same method signature as a method in the superclass is an example of method overloading.
Answer: False, this is an example of method overriding.
Find and correct the error in the following program.
class Vehicle { public double price; public Vehicle(double price) { this.price = price; } } class Car extends Vehicle { public Car(double price) { super.price = price; } }
Correction:
class Vehicle { public double price; public Vehicle(double price) { this.price = price; } } class Car extends Vehicle { public Car(double price) { super(price); } }
Or:
class Vehicle { public double price; public Vehicle(double price) { this.price = price; } public Vehicle() { } } class Car extends Vehicle { public Car(double price) { super.price = price; } }
Student Performance and Statistics
A histogram of student performance on percentage grades for Quiz 7 on Friday.
A table showing the average performance for each question in Quiz 7 on Friday.