What is the superclass in Java?
The superclass is the class being inherited from
Can a private method be overridden? Why or why not?
No, private methods are not inherited and cannot be overridden.
What was the name of the battle in the Pacific fought between the U.S. Navy and the Imperial Japanese Navy in June 1942?
Battle of midway
What is the purpose of a no-argument constructor?
A no-argument constructor provides a default way to instantiate an object.
Given a superclass and a subclass, which constructor is called first when creating a subclass object?
The constructor of the superclass is called first before the subclass constructor.
What keyword is used to inherit a class?
What is "extends"?
What is method overriding?
What is the process of redefining a method in a subclass?
What does polymorphism mean in Java?
What is the ability of a single action to be performed differently based on the object?
Can a subclass call its superclass’s constructor?
Yes, by using the "super" keyword.
Which of the following is a food item you can order at an Mcdonald's (think internationally too of course)
A. McKroket
B. Ayam McD Gulai
C. McArabia
D. Nasi Lemak
E. All of the above
F. None of the above
G. ONLY A and C.
E.
True or False: Java can have multiple child classes inherit from one parent class
True
What is method overloading?
The creation of methods with the same name but different parameters.
Which country that starts with K is not only the largest landlocked country in the world but also a transcontinental because part of it is in Eastern Europe and part is in Central Asia?
Kazakhstan
How are constructors invoked in an inheritance chain?
Constructors are invoked in the inheritance chain from superclass to subclass.
Write a simple code snippet demonstrating method overriding.
class Animal {
void speak() {
System.out.println("Animal speaks");
}
} class Dog extends Animal {
void speak()
{
System.out.println("Dog barks");
}
}
What is the purpose of the super keyword?
The "super" keyword is used to access members (methods or variables) of the superclass.
In Captain America: Civil War, who isn't on Iron Man's team?
Vision, Black Panther, Hawkeye, or Black Widow?
Hawkeye
How does polymorphism enhance maintainability?
Polymorphism allows code to work with different object types interchangeably, making updates easier.
What happens if a superclass has no default constructor?
A compilation error occurs if the subclass does not explicitly call a valid superclass constructor.
What is the output when a final method is called in a subclass object?
The final method executes as defined in the superclass, regardless of the subclass object.
Explain the difference between is-a and has-a relationships
An "is-a" relationship denotes inheritance (e.g., Dog is-a Animal). A "has-a" relationship denotes composition (e.g., Car has-a Engine).
Why must the overriding method have the same signature as the method in the superclass?
Because the overriding method needs to maintain compatibility with the superclass version.
Can static methods exhibit polymorphism? Why or why not?
No, static methods belong to the class, not the object, and cannot exhibit polymorphism.
Explain the order of constructor execution in a multi-level inheritance hierarchy.
Constructors are executed from the top of the hierarchy (superclass first) down to the subclass.
Find f'(x) (the derivative of f(x)) if f(x) = 7x^3 - 2x^2 + 4x - 5.
21x^2 - 4x + 4