
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Paper; Class: Fund. of Software Dev Honors; Subject: Computer Sci & Software Engr; University: Rose-Hulman Institute of Technology; Term: Unknown 1989;
Typology: Papers
1 / 1
This page cannot be seen from the preview
Don't miss anything!
Bo Miller Michael Hein Eric Stokes
The main advantage of inheritance is that it allows for the efficient reuse of code. Classes inherit code from others are known as children or subclasses, and the source of the reused code is a parent or superclass. Subclasses use the “Extends” clause to access their parent class. As a result of the Is-A relationship from child to parent, there is a certain degree of type compatibility between the two. For instance a Student object can be stored in a Person reference variable, but not the other way around. Visibility of fields and methods in inheritance is the same as every other class, except for the “Protected” type. This causes the code to visible to all subclass of the class the term is used in, but invisible to all other classes. Methods inherited by a class can have their body rewritten to act the way the child class wants. This is called method overriding. Overriding does not change the operations of parent classes, but it does enforce the new method across its own children until one of its children overrides the method. The constructor of a superclass can be called in any child constructor, but it must be the first statement in the child class’s constructor. The constructor can be called using the super reference (super()). Any fields or methods declared as “final” cannot be overridden or mutated because they are constants. Abstract Classes contain method stubs. Meaning that they are partially just templates for their descendants and contain methods with no executing code. Abstract Classes and methods cannot be instantiated because they contain only stubs and are not implemented outside of a child class. Any Class with unimplemented method stubs is Abstract. If a child class of an abstract class does not implement any of the method stubs of it’s parent than it must be declared abstract. Some programming languages will allow multiple inheritance, but Java doesn’t because of the possibility of name confusion for methods and fields. So one class can have many children but only one parent.