Like our natural language. Designed to facilitate the expression and communication ideas between people and computer Like our natural language. Designed.

Slides:



Advertisements
Similar presentations
Final and Abstract Classes
Advertisements

Introduction to Java 2 Programming
General OO Concepts Objectives For Today: Discuss the benefits of OO Programming Inheritance and Aggregation Abstract Classes Encapsulation Introduce Visual.
INHERITANCE BASICS Reusability is achieved by INHERITANCE
METHOD OVERRIDING Sub class can override the methods defined by the super class. Overridden Methods in the sub classes should have same name, same signature.
METHOD OVERRIDING 1.Sub class can override the methods defined by the super class. 2.Overridden Methods in the sub classes should have same name, same.
Module 8 “Polymorphism and Inheritance”. Outline Understanding Inheritance Inheritance Diagrams Constructors in Derived Classes Type Compatibility Polymorphism.
Inheritance Inheritance Reserved word protected Reserved word super
OBJECT-ORIENTED PROGRAMMING. What is an “object”? Abstract entity that contains data and actions Attributes (characteristics) and methods (functions)
 In inheritance the child (subclass) chooses its parent (superclass)  Remember - only public or “protected” methods and variables are inherited  Should.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Review of Object-Oriented Concepts in JAVA Object-Oriented Concepts supported by JAVA. Advantages of Object-Orientation. Inheritance. Abstract Classes.
CPSC150 Abstract Classes and Interfaces Chapter 10.
Object Oriented Concepts in Java Objects Inheritance Encapsulation Polymorphism.
Review of Object-Oriented Concepts in JAVA Object-Oriented Concepts supported by JAVA. Object-Oriented Concepts supported by JAVA. Advantages of Object-Orientation.
8.1 Classes & Inheritance Inheritance Objects are created to model ‘things’ Sometimes, ‘things’ may be different, but still have many attributes.
Inheritance and Polymorphism CS351 – Programming Paradigms.
Chapter 7 - Generalization/Specialization and Inheritance1 Chapter 7 Generalization/Specialization and Inheritance.
INTRODUCTION TO JAVA PROGRAMMING Chapter 1. What is Computer Programming?
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
OOPs Object oriented programming. Based on ADT principles  Representation of type and operations in a single unit  Available for other units to create.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
1 Object-Oriented Software Engineering CS Interfaces Interfaces are contracts Contracts between software groups Defines how software interacts with.
Programming With Java ICS201 University Of Ha’il1 Chapter 8 Polymorphism and Abstract Classes.
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
CS200 Algorithms and Data StructuresColorado State University Part 4. Advanced Java Topics Instructor: Sangmi Pallickara
Inheritance in the Java programming language J. W. Rider.
Java Objects and Classes. Overview n Creating objects that belong to the classes in the standard Java library n Creating your own classes.
OOP: Encapsulation,Abstraction & Polymorphism. What is Encapsulation Described as a protective barrier that prevents the code and data being randomly.
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.
JAVA COURSE 1 Computer Engineering Association. Compile your first program Public class Hello{ public class Hello(){ System.out.println(“Hello”); } puclic.
Summing Up Object Oriented Design. Four Major Components: Abstraction modeling real-life entities by essential information only Encapsulation clustering.
OOPs Object oriented programming. Abstract data types  Representationof type and operations in a single unit  Available for other units to create variables.
© 2007 Lawrenceville Press Slide 1 Chapter 8 Objects  A variable of a data type that is a class. Also called an instance of a class.  Stores data  Can.
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 – 9.4.
Access Modifiers Control which classes use a feature Only class-level variables may be controlled by access modifiers Modifiers 1. public 2. protected.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance Inheritance is the process of extending the functionality of a class by defining a new class that inherit,all the features of extending class.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
CSSE 375 Organizing Data – Part 1 Shawn and Steve Q1.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
YG - CS Concept of Encapsulation What is encapsulation? - data and functions/methods are packaged together in the class normally.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
POLYMORPHISM Chapter 6. Chapter Polymorphism  Polymorphism concept  Abstract classes and methods  Method overriding  Concrete sub classes and.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
COMPUTER SCIENCE & TECHNOLOGY DEGREE PROGRAMME FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UVA WELLASSA ‏ Properties of Object Oriented Programming.
JAVA ACCESS MODIFIERS. Access Modifiers Access modifiers control which classes may use a feature. A classes features are: - The class itself - Its member.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
Computer Programming II Lecture 5. Introduction to Object Oriented Programming (OOP) - There are two common programming methods : procedural programming.
OOP: Encapsulation &Abstraction
Inheritance ITI1121 Nour El Kadri.
Lecture 12 Inheritance.
Objects as a programming concept
Types of Programming Languages
Programming Language Concepts (CIS 635)
Object Oriented Programming
Object Oriented Analysis and Design
OOP’S Concepts in C#.Net
Can perform actions and provide communication
Can perform actions and provide communication
Interface.
METHOD OVERRIDING in JAVA
Can perform actions and provide communication
Static is one of the modifiers that determine variable and method characteristics. The static modifier associates a variable or method with its class.
Object-Oriented Programming
Object Oriented Programming
Final and Abstract Classes
Chapter 11 Inheritance and Encapsulation and Polymorphism
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
Presentation transcript:

Like our natural language. Designed to facilitate the expression and communication ideas between people and computer Like our natural language. Designed to facilitate the expression and communication ideas between people and computer

Object Oriented (OO)Programming (eg- Java,C++,Smalltalk and Eiffel) Functional Programming(eg-Lisp,Scheme,Haskell and ML) Logic (Declarative) Programming(eg-Prolog) Event Driven Programming(eg-Visual Basic and Java) Imperative Programming(eg-Cobol,Fortran,C and C++) Concurrent Programming(eg-SR) Object Oriented (OO)Programming (eg- Java,C++,Smalltalk and Eiffel) Functional Programming(eg-Lisp,Scheme,Haskell and ML) Logic (Declarative) Programming(eg-Prolog) Event Driven Programming(eg-Visual Basic and Java) Imperative Programming(eg-Cobol,Fortran,C and C++) Concurrent Programming(eg-SR)

Encapsulation Inheritance Polymorphism

If you want maintainability, flexibility, and extensibility!

If you want maintainability, flexibility, and extensibility, your design must include encapsulation. How do you do that?

public class Room{ public int size; public int name;... } public class OfficeRoom{ public static void main (String [] args) { Room b = new Room(); b.size =6; // Legal but bad!! }

Keep instance variables protected (with an access modifier, often private). Make public accessor methods, and force calling code to use those methods rather than directly accessing the instance variable.

Parent or Super Class Child or Sub Class

In object-oriented programming, polymorphism (from multiple forms") is the characteristic of being able to as particular symbol or "operator" in different contexts.

Public keyword Unrestricted.accessed from the code fragments of any class. Private keyword Only allowed within the code fragments of a class. Protected keyword Only allowed within the code fragments of a class and its sub class.

Static Method Abstract Method Final Method

Static method is assigned to a class and not to an object of that class. final class Math{ const PI = M_PI; static public function abs($num){ return abs($num); } echo Math::PI; echo ' '; echo Math::abs(-4.15); echo ' '; echo Math::sqrt(9); Static method is assigned to a class and not to an object of that class. final class Math{ const PI = M_PI; static public function abs($num){ return abs($num); } echo Math::PI; echo ' '; echo Math::abs(-4.15); echo ' '; echo Math::sqrt(9);

Declared as final can’t be overridden in a sub-class.

designed by the abstract keyword and no body. Used in abstract classes to impose a certain functionality on sub-classes of the abstract class.