Unit3 - Subjective Questions

CSE310 • Practice Questions with Detailed Answers

1

Define Inheritance in Java. Explain the different types of inheritance supported by Java with suitable diagrams or descriptions.

2

What is Method Overriding? List the rules that must be followed while overriding a method in Java.

3

Explain the usage of the super keyword in Java with examples. How is it used to invoke parent class constructors?

4

Differentiate between Method Overloading and Method Overriding in Java.

5

Explain the significance of the Object class in Java. Why do we override the toString() and equals() methods?

6

Discuss the final keyword in Java. Explain its effect when applied to a variable, a method, and a class.

7

What is Dynamic Method Dispatch (Runtime Polymorphism)? Demonstrate it with a code example.

8

Define an Abstract Class. How does it differ from a concrete class? Provide a syntax example.

9

What is an Interface in Java? Explain its syntax and how it supports multiple inheritance.

10

Compare and contrast Abstract Classes and Interfaces in Java.

11

What is the instanceof operator? Explain its purpose with a code snippet.

12

Elaborate on the concepts of Default and Static methods in Interfaces introduced in Java 8.

13

Can constructors be inherited? Explain the constructor chaining mechanism in inheritance.

14

Write a Java program to calculate the area of a Rectangle and a Circle using an abstract class Shape.

15

Explain the concept of Covariant Return Type with respect to method overriding.

16

Can we declare an interface as final? Explain why or why not.

17

What happens if a class implements two interfaces that have a default method with the same name and signature? How is this resolved?

18

Write a Java program to demonstrate the use of super to access a hidden field in the superclass.

19

Discuss the visibility of methods during overriding. Can we reduce the visibility of an inherited method?

20

How does Java support inheritance between interfaces? Explain with syntax.