Java OCA OCP Practice Question 1250

Question

Which of the following statements about inheritance is true?

  • A. Inheritance allows objects to access commonly used attributes and methods.
  • B. Inheritance always leads to simpler code.
  • C. All primitives and objects inherit a set of methods.
  • D. Inheritance allows you to write methods that reference themselves.


A.

Note

Inheritance is often about improving code reusability, by allowing subclasses to inherit commonly used attributes and methods from parent classes, making Option A the correct answer.

Option B is incorrect.

Inheritance can lead to either simpler or more complex code, depending on how well it is structured.

Option C is also incorrect.

While all objects inherit methods from java.lang.Object, this does not apply to primitives.

Option D is incorrect because methods that reference themselves are not a facet of inheritance.




PreviousNext

Related