Core Java Unit 3: Inheritance and Interfaces

Easy Level Questions (5 Marks Each)

(Bloom’s Taxonomy: Remembering, Understanding)

1.     What is inheritance in Java? List one key advantage of using inheritance.

2.     Differentiate between a superclass and a subclass in the context of Java inheritance.

3.     What is the purpose of the super keyword in Java? Give a simple scenario where it is used.

4.     Define method overriding. What is a prerequisite for a method to be overridden?

5.     What is an abstract class in Java? Can an abstract class be instantiated directly?

6.     What is an interface in Java? Can an interface contain concrete method implementations?

7.     Explain the use of the final keyword when applied to a method.


Moderate Level Questions ( 5 Marks Each)

(Bloom’s Taxonomy: Understanding, Applying, Analyzing)

8.     Explain the concept of "Types of Inheritance" supported by Java. Discuss why multiple inheritance of classes is not allowed in Java.

9.     Write a Java program to demonstrate single-level inheritance. Create a Shape class with a method display(), and a Circle class that extends Shape and adds a radius attribute.

10.                        Describe the significance of the super keyword in two distinct contexts: calling a superclass constructor and accessing a superclass member. Provide Java code examples for both.

11.                        Explain "Method Overriding" and "Runtime Polymorphism" in Java. Provide a code example demonstrating how runtime polymorphism is achieved through method overriding.

12.                        Discuss the implications of using the final keyword with a class. When would it be appropriate to declare a class as final?

13.                        Design an abstract class Vehicle with an abstract method start(). Create two concrete subclasses, Car and Motorcycle, that implement the start() method differently.

14.                        Explain the difference between an abstract class and an interface in Java. When would you choose to use an interface over an abstract class?

15.                        Write a Java program to define an interface Drawable with a method draw(). Implement this interface in two classes, Circle and Rectangle, providing their own implementations of the draw() method.

16.                        Consider a scenario where a final method is present in a superclass. Can a subclass override this method? Justify your answer with respect to Java’s inheritance rules.


Difficult Level Questions (5 Marks Each)

(Bloom’s Taxonomy: Analyzing, Evaluating, Creating)

18.                        Design a Java program using inheritance to model a "University Employee" system.

o    Create an abstract class Employee with common attributes (e.g., name, employeeId) and an abstract method calculateSalary().

o    Create two concrete subclasses: Faculty (with additional attributes like department, designation) and Staff (with additional attributes like jobTitle).

o    Implement calculateSalary() uniquely for Faculty (e.g., based on designation) and Staff (e.g., based on fixed monthly salary).

o    Demonstrate runtime polymorphism by creating an array of Employee objects, populating it with Faculty and Staff instances, and calling calculateSalary() on each.

19.                        Evaluate the benefits and drawbacks of using multiple interfaces versus a single abstract class for achieving polymorphism in complex Java applications. Under what specific conditions would multiple interfaces be a superior design choice, and when would an abstract class be more appropriate? Provide a detailed justification with examples.