Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Notes on Inheritance - Fundamentals of Software Development | CSSE 221, Papers of Computer Science

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

Pre 2010

Uploaded on 08/18/2009

koofers-user-bkf
koofers-user-bkf 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Bo Miller
Michael Hein
Eric Stokes
Inheritance
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.

Partial preview of the text

Download Notes on Inheritance - Fundamentals of Software Development | CSSE 221 and more Papers Computer Science in PDF only on Docsity!

Bo Miller Michael Hein Eric Stokes

Inheritance

 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.