asked 151k views
0 votes
Consider the following statements:

I. A class can be declared as both abstract and final.
II. A class declared as final can be extended by defining a sub-class.
III. Resolving calls to methods dynamically at run-time is called late binding.
IV. The class Object defined by Java need not be a super class of all other classes.
Identify the correct statement from the following:
(a) Both (I) and (II) above
(b) Both (III) and (IV) above
(c) Both (I) and (III) above
(d) Both (II) and (IV) above
(e) Only (III) above.

asked
User Tigra
by
7.7k points

1 Answer

4 votes

Final answer:

The correct statement is III, which states that resolving calls to methods dynamically at run-time is called late binding. A class cannot be both abstract and final, a final class cannot be extended, and the Object class is a superclass of all other classes in Java.

Step-by-step explanation:

The correct statement among the ones given is 'Resolving calls to methods dynamically at run-time is called late binding', which is listed as (III). Therefore, the right choice is (e) Only (III) above. Examining each of the statements provided:

  • (I) A class cannot be declared both abstract and final. An abstract class is supposed to be extended and its abstract methods implemented, while a final class cannot be extended, making the two concepts mutually exclusive.
  • (II) A class declared as final cannot be extended by defining a sub-class, which is the exact purpose of marking a class as final: to prevent inheritance.
  • (III) Resolving calls to methods dynamically at run-time is indeed known as late binding or dynamic dispatch, and it is a key feature of polymorphism in object-oriented languages such as Java.
  • (IV) The class Object in Java is designed to be a super class of all other classes. If a class does not explicitly extend another class, it implicitly extends Object.

answered
User Rohitverma
by
8.2k points