Lecture-3 - Instantiation in Inheritance Developer is one category of employee and Manager is another Neither of these categories can be used to

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
Object Oriented Programming - Introduction R.B. Lenin Winter 2006 DA-IICT 29 Instantiation in Inheritance Developer is one category of employee and Manager is another Neither of these categories can be used to identify an individual and they are just templates John ” is an example of a developer and hence an instance of a particular class of things known as developers
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Object Oriented Programming - Introduction R.B. Lenin Winter 2006 DA-IICT 30 Inheritance of Common Information ± All people have a name and all employees have a nominated department whether they are permanent or temporary ± In turn all classes below Employee inherit the concept of a department ± “John” belongs to the department “ Payroll
Background image of page 2
Object Oriented Programming - Introduction R.B. Lenin Winter 2006 DA-IICT 31 Abstract Classes in Inheritance The example defines a number of classes ± Employee ± Permanent Employee ± Temporary Employee of which we have no intention of making an example These are termed as abstract classes and are intended as placeholders for common features
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Object Oriented Programming - Introduction R.B. Lenin Winter 2006 DA-IICT 32 Inheritance of Defaults In the example, Permanent Employees earn a default salary of £14,000 a year It does not mean that all types of employee have that default. Managers have a default of £30,000 Therefore a class can overwrite the defaults defined in one of its parents
Background image of page 4
Object Oriented Programming - Introduction R.B. Lenin Winter 2006 DA-IICT 33 Single Inheritance If a class inherits from only one other class, it is called single inheritance All OOP languages support single inheritance
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Object Oriented Programming - Introduction R.B. Lenin Winter 2006 DA-IICT 34 Multiple Inheritance If a class inherits from more than one other classes, it is called multiple inheritance Not all OOP languages support multiple inheritance Java does not support multiple inheritance but C++
Background image of page 6
Object Oriented Programming - Introduction R.B. Lenin Winter 2006 DA-IICT 35 Basic Principles of OOP ± Encapsulation ± Inheritance ± Polymorphism
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Object Oriented Programming - Introduction R.B. Lenin Winter 2006 DA-IICT 36 Polymorphism This word is derived from the Greek word “Polymorphos” means “having many forms” A dog’s sense of smell is polymorphic ± if it smells a cat, it will bark and run after it ± if it smells food, it will salivate and run to it The difference is what is being smelled: the type of data being operated upon the dog’s nose
Background image of page 8
Object Oriented Programming - Introduction R.B. Lenin Winter 2006 DA-IICT 37 Polymorphism ± The variable ‘motor’ is an
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/15/2010 for the course CSE IT325 taught by Professor Maniklaldas during the Spring '09 term at Punjab Engineering College.

Page1 / 38

Lecture-3 - Instantiation in Inheritance Developer is one category of employee and Manager is another Neither of these categories can be used to

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online