04-29-2011, 07:44 AM
Sub typing (extension) means that derived class is behaviourally compatible with base class. In extension derived class have all the characteristics of base class plus some extra characteristics (derived class own characteristics). Class A is a subtype of B if A can be used in any situation where B can be used. It means that A has at least all the methods of B with the appropriate types, plus any instance variable.
Examples:
Person is a base class and Student class is derived from Person class
Person
Name
Age
Gender
Eats
Walks
Student
Program
StudyYear
Study
TakeExam
Student class has two extra attributes program and studyYear. Similarly it has extended behaviour by adding Study and TakeExam. Also Student class has all the characteristics of base class Person.
Examples:
Person is a base class and Student class is derived from Person class
Person
Name
Age
Gender
Eats
Walks
Student
Program
StudyYear
Study
TakeExam
Student class has two extra attributes program and studyYear. Similarly it has extended behaviour by adding Study and TakeExam. Also Student class has all the characteristics of base class Person.
0300-9520262
Get solution in 24 hour |cpmputer & internet
mileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
