When adding a new derived class, which statement is accurate about changes to the base class?

Prepare for the Computer Science (CS) III Exam. Study with multiple choice questions, detailed explanations, and comprehensive resources. Boost your confidence and ace the exam!

When adding a new derived class, it is indeed accurate that a derived class may add new attributes without altering the base class. This concept is fundamental to the principles of inheritance in object-oriented programming.

In this context, the base class serves as a template or blueprint from which new classes (the derived classes) can be created. The derived class inherits the properties and behaviors (methods) of the base class but is free to introduce additional attributes and methods that are specific to its own functionality. This feature allows for the extension of class behavior without modifying the existing code in the base class, which promotes code reusability and maintainability. Thus, new attributes in the derived class enrich its functionality while keeping the base class intact.

The other statements do not accurately reflect the principles of inheritance. For example, it's not mandatory for the programmer to change the base class when creating a derived class, which directly contradicts the idea of extending existing functionality. Additionally, there is no requirement for the base class and derived class to maintain the same number of attributes; they can vastly differ depending on their design and purpose. Lastly, the base class remains usable and relevant even after derived classes are created; it can still be instantiated independently unless explicitly designed otherwise.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy