Chapter 10 Thinking in Objects

Slides:



Advertisements
Similar presentations
OOP Abstraction Classes Class Members: Properties & Methods Instance (object) Encapsulation Interfaces Inheritance Composition Polymorphism Using Inheritance.
Advertisements

Chapter 1 Inheritance University Of Ha’il.
Module 8 “Polymorphism and Inheritance”. Outline Understanding Inheritance Inheritance Diagrams Constructors in Derived Classes Type Compatibility Polymorphism.
1 Chapter 6: Extending classes and Inheritance. 2 Basics of Inheritance One of the basic objectives of Inheritance is code reuse If you want to extend.
Week 8 Recap CSE 115 Spring Composite Revisited Once we create a composite object, it can itself refer to composites. Once we create a composite.
Inheritance Java permits you to use your user defined classes to create programs using inheritance.
Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
Advanced Programming in Java
Sadegh Aliakbary Sharif University of Technology Fall 2010.
L3-1-S1 OO Concepts © M.E. Fayad SJSU -- CMPE Software System Engineering Dr. M.E. Fayad, Professor Computer Engineering Department, Room.
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 8.1 – 8.5.
Encapsulation, Inheritance & Interfaces CSE 115 Spring 2006 February 27, March 1 & 3, 2006.
CSE 115 Week 10 March , Announcements March 21 – Lab 7 Q & A in lecture March 21 – Lab 7 Q & A in lecture March 26 – Exam 7 March 26 – Exam.
CSCI 143 OOP – Inheritance 1. What is Inheritance? A form of software reuse Create a new class from an existing class – Absorb existing class data and.
CS 106 Introduction to Computer Science I 04 / 16 / 2010 Instructor: Michael Eckmann.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
CPSC150 Interfaces Chapter CPSC150 Inheritance Review No different than any other class. Has no access to or information about subclasses class.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter N - 1 Chapter 13 Polymorphism is-a relationships Interfaces.
ISE 582: Web Technology for Industrial Engineers University of Southern California Department of Industrial and Systems Engineering Lecture 4 JAVA Cup.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Computer Science I Inheritance Professor Evan Korth New York University.
Inheritance. © 2004 Pearson Addison-Wesley. All rights reserved 8-2 Inheritance Inheritance is a fundamental object-oriented design technique used to.
OOPs Object oriented programming. Based on ADT principles  Representation of type and operations in a single unit  Available for other units to create.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
OO (Object Oriented) Programming Chapter 21 IB103 Week 12.
1 Java Inheritance. 2 Inheritance On the surface, inheritance is a code re-use issue. –we can extend code that is already written in a manageable manner.
Object Oriented Programming: Java Edition By: Samuel Robinson.
Specialization and Inheritance Chapter 8. 8 Specialization Specialized classes inherit the properties and methods of the parent or base class. A dog is.
JAVA WORKSHOP SESSION – 3 PRESENTED BY JAYA RAO MTech(CSE) NEWTON’S INSTITUTE OF ENGINEERING 1.
Inheritance comp249. Question 1 What type of inheritance does Java have? a) single inheritance b)double inheritance c) multiple inheritance d)class inheritance.
8. Inheritance “Is-a” Relationship. Topics Creating Subclasses Overriding Methods Class Hierarchies Abstract Class Inheritance and GUIs The Timer Class.
Inheritance Inheritance allows a programmer to derive a new class from an existing one The existing class is called the super class, or parent class,
OOPs Object oriented programming. Abstract data types  Representationof type and operations in a single unit  Available for other units to create variables.
Interfaces Chapter 9. 9 Creating Interfaces An interface is a contract. Every class that implements the interface must provide the interface’s defined.
Coming up: Inheritance
Topics Inheritance introduction
© 2007 Lawrenceville Press Slide 1 Chapter 9 Inheritance  One class is an extension of another.  Allows a class to define a specialized type of an existing.
Basic Concepts of OOP.  Object-Oriented Programming (OOP) is a type of programming added to php5 that makes building complex, modular and reusable web.
Inheritance & Polymorphism Android Club Agenda Inheritance Polymorphism.
A Introduction to Computing II Lecture 3: Interfaces and Inheritance Fall Session 2000.
SUBCLASSES - JAVA. The Purpose of Subclasses Class Farm String getOwner() void setOwner(String s) int getSize() void setSize(int s) Class DairyFarm String.
1 Inheritance One of the goals of object oriented programming is code reuse. Inheritance is one mechanism for accomplishing code reuse. It allows us to.
Comp1004: Object Oriented Design I Abstract Classes and Interfaces.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Programming in Java: lecture 7
Advanced Programming in Java
Advanced Programming in Java
Interface, Subclass, and Abstract Class Review
One class is an extension of another.
Inheritance Inheritance allows a programmer to derive a new class from an existing one The existing class is called the super class, or parent class,
Week 4 Object-Oriented Programming (1): Inheritance
PRINCIPALES OF OBJECT ORIENTED PROGRAMMING
Road Map Inheritance Class hierarchy Overriding methods Constructors
3 Fundamentals of Object-Oriented Programming
One class is an extension of another.
MSIS 670 Object-Oriented Software Engineering
Inheritance, Polymorphism, and Interfaces. Oh My
Pre-AP® Computer Science Quiz
Advanced Programming Behnam Hatami Fall 2017.
Chapter 11 Inheritance and Polymorphism
Java Inheritance.
Advanced Programming in Java
Inheritance and Polymorphism
PreAP Computer Science Quiz
Object Oriented Analysis and Design
Object-Oriented Programming
Chapter 11 Inheritance and Encapsulation and Polymorphism
Topics OOP Review Inheritance Review Abstract Classes
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
Presentation transcript:

Chapter 10 Thinking in Objects

Principle of OOP Inheritance Abstraction Encapsulation Polymorphism Also know as (APIE)

Inheritance and Composition A class can extend another class. Inheritance implements the “ IS a” relationship between objects A class can implements interface, methods members from its parent class.

Inheritance and Composition Is- A and Has –A Inheritance VS Composition Favor Composition Polymorphism Interfaces

Is-A and Has-A relationship Classes depend on another class Classes are related via Is –A or Has –A relationship Cat-> Animal = IS-A Car->Wheel, Engine =Has -A Train->Wheel,Engine=Has -A Car,Truck-> Vehicle= Is-A HAS-A=Composition (compose) IS-A=Inheritance(subtype) Reuse code

Inheritance (Is-A) Animal Cat Animal is a base class cat class inheritances from animal Animal Cat

Inheritance Syntax Java Supports only public inheritance A is a Superclass and B is a Subclass

Inheritance Syntax In order to call the constructor of superclass(A) the keyword super is used

Composition (Has-A) car wheel Engine Something is made up of other parts Car contains wheel and engine It is also called aggregation car wheel Engine

Composition (Has-A):aggregation Composition(HAS-A) simply mean use of instance variables that are references to other objects. For example: Maruti has Engine, or House has Bathroom

Composition (Has-A):aggregation

Aggregation Lab

Inheritance Lab Follow the instructions provided on Lab9