Discuss the ways in which inheritance promotes defect reduction.
9.7 (protected vs private) Some programmers prefer not to use protected access, because they
believe it breaks the encapsulation of the superclass. Discuss the relative merits of using
protected access vs using private access in superclass.
9.11 (super) Explain two usages of the super keyword, and state some of the advantages of each
type of usage.
9.12 (Using super) A method decode() is declared in a parent class, and also the child. How can
you access the decode() of the parent from within the child?
2-3 sentences for each
Solution
9.7) superclass\' protected members are accessible by an indirect subclass.most compilers will
complain that the extened class doesn\'t exist.(import object.classname)
9.11)most compilers will complain that the extened class doesn\'t exist.super is used to refer
immediate parent class instance variable.super() is used to invoke immediate parent class
constructor.super is used to invoke immediate parent class method.
9.4)able to reuse code for different classes by putting it in a common superclass
9.12)extending from virtual or abstract classes can use super.You can only use super in methods
that are designated with the override keyword.