Basics of Inheritance
Overriding and Overloading
Polymorphism Concepts
Constructors and Initialization
Code Tracing
100

What is the superclass in Java?

The superclass is the class being inherited from

100

Can a private method be overridden? Why or why not?

No, private methods are not inherited and cannot be overridden.

100

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

100

What is the purpose of a no-argument constructor?

A no-argument constructor provides a default way to instantiate an object.

100

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.

200

What keyword is used to inherit a class?

What is "extends"?

200

What is method overriding?

What is the process of redefining a method in a subclass?

200

What does polymorphism mean in Java?

What is the ability of a single action to be performed differently based on the object?

200

Can a subclass call its superclass’s constructor?

Yes, by using the "super" keyword.

200

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.

300

True or False: Java can have multiple child classes inherit from one parent class

True

300

What is method overloading?

The creation of methods with the same name but different parameters.

300

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

300

How are constructors invoked in an inheritance chain?

Constructors are invoked in the inheritance chain from superclass to subclass.

300

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"); 

}

}

400

What is the purpose of the super keyword?

The "super" keyword is used to access members (methods or variables) of the superclass.

400

In Captain America: Civil War, who isn't on Iron Man's team? 

Vision, Black Panther, Hawkeye, or Black Widow?

Hawkeye

400

How does polymorphism enhance maintainability?

Polymorphism allows code to work with different object types interchangeably, making updates easier.

400

What happens if a superclass has no default constructor?

A compilation error occurs if the subclass does not explicitly call a valid superclass constructor.

400

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.

500

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).

500

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.

500

Can static methods exhibit polymorphism? Why or why not?

No, static methods belong to the class, not the object, and cannot exhibit polymorphism.

500

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.

500

Find f'(x) (the derivative of f(x)) if f(x) = 7x^3 - 2x^2 + 4x - 5. 

21x^2 - 4x + 4