School of Computer Science & Information Technology G6DICP - Lecture 16 Inheritance.

Slides:



Advertisements
Similar presentations
How do we classify vertebrates?
Advertisements

5th Grade Plants & Animals Vocabulary
What am I? A quiz based on the Classification of Vertebrates
Classification of Animals
Classification of Animals
Animal Classifications
Click an animal to find out more
1 G54PRG Programming Lecture 1 Amadeo Ascó Adam Moore 17 Inheritance.
Mrs. Cummings 3rd Grade Animals Unit
Young animals inherit their features from their parents.
Living Things.
Classification of Animals
Classification of Animals IES “Lorenzo Hervás y Panduro” 1º ESO Curso 2010/2011.
© Oxford University Press Vertebrate groups What is the same about all the animals?All the animals are vertebrates - they have backbones.
Science Vocabulary All About Animals.
Good to see you!. CLASS POINTS Color Team POINTS!
There are many kinds of animals. Animals can be put into groups based upon their characteristics. Some animals do not have backbones.
Living Things A Quiz About Plants and Animals. What are living things made from?
Amphibians 1.Amphibian are cold blooded animals.
CLASSIFYING ANIMALS. Classifying Animals Vertebrates: Animals with backbone. Invertebrates: Animals without backbone.
Grouping & Identifying Living Things
Invertebrates don’t have a backbone Insert video 1 (invertebrates)
Classify animals as scientists do. Classify animals as scientists do Scientists first divide animals into two main groups according to whether they have.
Inheritance Chapter 10 Programs built from objects/instances of classes An O.O. approach – build on earlier work. Use classes in library and ones you have.
Groups All life on earth falls into categories. There is the Plant kingdom, which is divided into ferns and flowering plants. The animal kingdom which.
Animal Classification s. There are five different ways we can class animals...
Animal Groups Your Name.
The Animal Kingdom Animals are broadly divided into vertebrates and invertebrates. Animals Vertebrates Invertebrates.
Kenny’s Animal Classes!
Classification of Living Things / Animals. Classification of Living Things Scientists estimate that there are between 3 million and 100 million species.
INVERTEBRATE ANNELIDS MOLLUSKS ARACHNIDS CRUSTACEANS
Day 19. SIPPS Spelling Spelling TEST Daily Fix It What hapened to the dollar in my drawer. Dan spended it at the fare.
 Mrs.Agger’s Fourth Grade Class Animal Kingdom!!!!!
Classification of Animals Part 2 Quiz! Draw a box at the top to keep track of your points. Write the letter of the correct answer. Have your dry-erase.
Science Types of Animals and Their Traits Third Grade.
ANIMALS Unit 6.. dolphin(s) big smile fin beak lion(s) mane.
Unit 7 Lesson 2 How Can We Classify Vertebrates? Copyright © Houghton Mifflin Harcourt Publishing Company.
How Animals Live Chapter Two. What All Animals Need water food oxygen shelter.
How Can We Group Animals?
Life Cycles Review Game
Animals of Rainforest.
Classification of Animals
Vertebrates There are five groups of vertebrates.
What is Classification?
Natural sciences 2.
Variation and Classification
Variation and Classification
Inheritance, Polymorphism, and Interfaces. Oh My
Pre-AP® Computer Science Quiz Key
Pre-AP® Computer Science Quiz
Variation and Classification
Interdependence and Adaptation
ANIMAL KINGDOM VERTEBRATES INVERTEBRATES DANIEL.
What is the difference between a Vertebrate and an Invertebrate?
Classification of Animals
Classification of Animals
Classification of Animals
Classification.
Classification of Animals
Classification of Animals
Classification of Animals
Variation and Classification
PreAP Computer Science Quiz
Classification of Animals
1/31/12 Objective: Understand that the characteristics of organisms change over time Warm-Up: Give one example of how life on earth has changed since.
Variation and Classification
Classification of Animals
Vertebrate Invertebrate
Inheritance Lakshmish Ramaswamy.
Classification of Animals
Presentation transcript:

School of Computer Science & Information Technology G6DICP - Lecture 16 Inheritance

2 Definition of classes Classes may be defined in terms of other classes Classes may be defined in terms of other classes For example: For example: Tigers, cheetahs, leopards & jaguars are all types of cats Tigers, cheetahs, leopards & jaguars are all types of cats Class tiger is a subclass of class cat Class tiger is a subclass of class cat Ball point pens, fountain pens & marker pens are all types of pens Ball point pens, fountain pens & marker pens are all types of pens Ball point pen is a subclass of class pen Ball point pen is a subclass of class pen Subclasses inherit properties from their parent Subclasses inherit properties from their parent All cats are furry, and have big teeth - therefore tigers are furry and have big teeth All cats are furry, and have big teeth - therefore tigers are furry and have big teeth All pens contain ink - therefore marker pens contain ink All pens contain ink - therefore marker pens contain ink

3 Class hierarchies Classes are arranged into hierarchies Classes are arranged into hierarchies Subclasses provide specialised behaviour, whereas superclasses are more general. Subclasses provide specialised behaviour, whereas superclasses are more general. Inheritance is one-way (ie downwards) Inheritance is one-way (ie downwards) All Java classes are ultimately inherited from class Object All Java classes are ultimately inherited from class Object Methods are inherited down a hierarchy Methods are inherited down a hierarchy They may be left unchanged They may be left unchanged They may be modified (ie overridden) They may be modified (ie overridden)

4 Inheritance - of properties Invertebrates Invertebrates Vertebrates Backbone Vertebrates Backbone Fish Scales Fish Scales Amphibians Amphibians Reptiles Reptiles Birds Feathers Birds Feathers Mammals Fur Mammals Fur Bats Wings Bats Wings Cattle Hooves Cattle Hooves Carnivores Big Teeth Carnivores Big Teeth Dogs Dogs Cats Cats Lion Mane Lion Mane Tiger Stripes Tiger Stripes Animals

5 Inheritance - of properties Invertebrates Invertebrates Vertebrates Backbone Vertebrates Backbone Fish Scales Fish Scales Amphibians Amphibians Reptiles Reptiles Birds Feathers Birds Feathers Mammals Fur Mammals Fur Bats Wings Bats Wings Cattle Hooves Cattle Hooves Carnivores Big Teeth Carnivores Big Teeth Dogs Dogs Cats Cats Lion Mane Lion Mane Tiger Stripes Tiger Stripes Animals Tigers are vertebrates - thus they have a backbone

6 Inheritance - of properties Invertebrates Invertebrates Vertebrates Backbone Vertebrates Backbone Fish Scales Fish Scales Amphibians Amphibians Reptiles Reptiles Birds Feathers Birds Feathers Mammals Fur Mammals Fur Bats Wings Bats Wings Cattle Hooves Cattle Hooves Carnivores Big Teeth Carnivores Big Teeth Dogs Dogs Cats Cats Lion Mane Lion Mane Tiger Stripes Tiger Stripes Animals Tigers are not birds - they do not have feathers!

7 Inheritance - of properties Invertebrates Invertebrates Vertebrates Backbone Vertebrates Backbone Fish Scales Fish Scales Amphibians Amphibians Reptiles Reptiles Birds Feathers Birds Feathers Mammals Fur Mammals Fur Bats Wings Bats Wings Cattle Hooves Cattle Hooves Carnivores Big Teeth Carnivores Big Teeth Dogs Dogs Cats Cats Lion Mane Lion Mane Tiger Stripes Tiger Stripes Animals Tigers are carnivores - they have big teeth

8 Inheritance of behaviour (methods) Pencil Method - sharpen Pencil Method - sharpen Pen Property - Ink Colour Pen Property - Ink Colour Ball-point pen Ball-point pen Fountain pen Method - fill with ink Fountain pen Method - fill with ink Felt-tip pen Method - remove cap Felt-tip pen Method - remove cap Permanent Marker pen Permanent Marker pen Dry Wipe pen Dry Wipe pen Writing Implements Method - Draw Line

9 Sub and Super Classes Pencil Pencil Pen Superclass Pen Superclass Ball-point pen Ball-point pen Fountain pen Fountain pen Felt-tip pen Class Felt-tip pen Class Permanent Marker pen Subclass Permanent Marker pen Subclass Dry Wipe pen Subclass Dry Wipe pen Subclass Writing Implements Ancestor Class Consider the following classes, relative to Felt-tip pen

10 The extends reserved word Class modifier Class modifier Declares one class to be a subclass of another Declares one class to be a subclass of another For example: class Tiger extends Cat { … } For example: class Tiger extends Cat { … }

11 The super reserved word The super reserved word refers to the immediate superclass of a class. The super reserved word refers to the immediate superclass of a class. The superclass constructor may be invoked by calling super. The superclass constructor may be invoked by calling super. On its own super invokes the constructor of the immediate superclass. On its own super invokes the constructor of the immediate superclass.