Type Here to Get Search Results !

Which of the following statements is true regarding the final keyword in OOP?

0

 Which of the following statements is true regarding the final keyword in OOP?

A) It can be applied to variables only.
B) It prevents a class from being subclassed.
C) It allows for method overriding.
D) It can only be used with abstract classes.

Answer: B) It prevents a class from being subclassed.

Explanation: In many programming languages, the final keyword is used to denote that a class cannot be subclassed (in the case of classes), a method cannot be overridden (in the case of methods), or a variable's value cannot be changed (in the case of variables). This is useful for creating immutable classes and ensuring certain behaviors are fixed.

Post a Comment

0 Comments