04-29-2011, 07:45 AM
A set of classes and their interrelationships is called class hierarchy.
When a method is invoked on an object it is first looked for in the object’s class, then the superclass of that class and son on up the hierarchy until it is found. Thus a class need only define those methods which are specific to it, and inherit methods from all its superclasses.
Example:
Class C is derived from class of B, and B class is derived from class A.
Now class C object accessed the method (for example) getAge(), then it first looked in class C, if not found, then looked in class B, if not found, then looked in class A.
When a method is invoked on an object it is first looked for in the object’s class, then the superclass of that class and son on up the hierarchy until it is found. Thus a class need only define those methods which are specific to it, and inherit methods from all its superclasses.
Example:
Class C is derived from class of B, and B class is derived from class A.
Now class C object accessed the method (for example) getAge(), then it first looked in class C, if not found, then looked in class B, if not found, then looked in class A.
0300-9520262
Get solution in 24 hour |cpmputer & internet
mileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
