By : Robert Apeldorn. What is OOP?  Object-oriented programming is a programming paradigm that uses “objects” to design applications and computer programs.

Slides:



Advertisements
Similar presentations
INHERITANCE BASICS Reusability is achieved by INHERITANCE
Advertisements

BITS Pilani Avinash Gautam Department of Computer Science and Information Systems.
1 l Inheritance Basics l Programming with Inheritance l Dynamic Binding and Polymorphism Inheritance.
OBJECT-ORIENTED PROGRAMMING CONCEPTS (Review). What is an Object? What is an Object? Objects have states and behaviors. Example: A dog has states - color,
Classes and Objects in Java. What Is an Object?. An object is a software bundle of related state and behavior. Software objects are often used to model.
INSTRUCTOR: SHIH-SHINH HUANG Windows Programming Using Java Chapter3: Introduction to Classes and Objects 1.
Inheritance. In this chapter, we will cover: The concept of inheritance Extending classes Overriding superclass methods Working with superclasses that.
What is an object? Your dog, your desk, your television set, your bicycle. Real-world objects share two characteristics: They all have state and behavior;
EEC-681/781 Distributed Computing Systems Java Tutorial Wenbing Zhao Cleveland State University
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Object-oriented Programming Concepts
Object Oriented Paradigm Programming Paradigms En Mohd Norafizal A.Aziz.
8.1 Classes & Inheritance Inheritance Objects are created to model ‘things’ Sometimes, ‘things’ may be different, but still have many attributes.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
INTRODUCTION TO JAVA PROGRAMMING Chapter 1. What is Computer Programming?
Java Objects and Classes. 3-2 Object Oriented Programming  An OO program models the application as a world of interacting objects.  A typical Java program.
Inheritance using Java
Programming Languages and Paradigms Object-Oriented Programming.
______________________________________________________________________________________ SCHOOL OF INTERACTIVE ARTS + TECHNOLOGY [SIAT] |
Chapter 4 Objects and Classes.
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
Object Oriented Programming Concepts Fatih University Ceng-104-A Introduction to Object Oriented Programming Harun Reşit Zafer This is a slide version.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
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.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 2 1 Java Inheritance.
Java. Features of Java Architecture Neutral and Portable o Write once, run anywhere o Java Virtual Machine (JVM) Object Oriented o Classes encapsulate.
CS200 Algorithms and Data StructuresColorado State University Part 4. Advanced Java Topics Instructor: Sangmi Pallickara
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
CSC 142 Computer Science II Zhen Jiang West Chester University
Encapsulation, Inheritance & Polymorphism. OOP Properties Encapsulation ­The process of creating programs so that information within a class is not accessible.
Inheritance The Basics in Java. Definition  A class that is derived from another class is called a subclass (also a derived class, extended class, or.
Object Oriented Programming Concepts. Object ► An object is a software bundle of related state and behavior. ► Software objects are often used to model.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
Chapter 3 Introduction to Classes and Objects Definitions Examples.
Chapter 10: Introduction to Inheritance. Objectives Learn about the concept of inheritance Extend classes Override superclass methods Call constructors.
JAVA Programming (Session 4) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Classes, Interfaces and Packages
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
What Is a Package? A package is a namespace that organizes a set of related classes and interfaces. Conceptually you can think of packages as being similar.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Seventh step for Learning C++ Programming CLASS Declaration Public & Private Constructor & Destructor This pointer Inheritance.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
Introduction to Object-oriented Programming
Programming paradigms
What is an Object Objects are key to understanding object-oriented technology. An object can be considered a "thing" that can perform a set of related.
University of Central Florida COP 3330 Object Oriented Programming
Inheritance and Polymorphism
University of Central Florida COP 3330 Object Oriented Programming
EEC 484 Computer Networks Java Tutorial #1 Wenbing Zhao
Object-Oriented Programming
Abstract Data Types and Encapsulation Concepts
البرمجة الكينونية بلغة جافا 1294
Interface.
Object-Oriented Programming
Interfaces.
Java Programming, Second Edition
Inheritance.
Object-Oriented Programming
Introducing Java.
Object-Oriented Programming
Topics OOP Review Inheritance Review Abstract Classes
CSG2H3 Object Oriented Programming
INTERFACES Explained By: Sarbjit Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
Presentation transcript:

By : Robert Apeldorn

What is OOP?  Object-oriented programming is a programming paradigm that uses “objects” to design applications and computer programs

Terms needed to know  Class blueprint or prototype from which objects are created  Object data structures consisting of data fields and methods together with their interactions  Inheritance "Subclasses" are more specialized versions of a class, which inherit attributes and behaviors from their parent classes, and can introduce their own.  Interface group of related methods with empty bodies  Package namespace that organizes a set of related classes and interfaces

Objects  An object stores its state in fields and exposes its behavior through methods  Methods operate on an object's internal state and serve as the primary mechanism for object-to-object communication

Example of a bicycle

Pros with Objects  Modularity The source code for an object can be written and maintained independently of the source code for other objects  Information-hiding By interacting only with an object's methods, the details of its internal implementation remain hidden from the outside world  Code re-use If an object already exists, you can use that object in your program. This allows specialists to implement/test/debug complex, task-specific objects, which you can then trust to run in your own code  Pluggability and debugging ease If a particular object turns out to be problematic, you can simply remove it from your application and plug in a different object as its replacement

Classes  The basic structure of Java programs with user defined classes: public class ClassName { public static void main(String[] args) { program statements } user defined methods } user defined classes

Class Definitions  Constructors special block of statements called when an object is created, either when it is declared or when it is dynamically constructed on the heap through the keyword “new”  Methods consists of a sequence of programming statements to perform an action  Field data member of the class

Different Class Modifiers  Public Can be accessed outside the program  Private Cannot be accessed outside of the current class  Protected A subclass can directly access a superclass Ex) subclass square can access class shape

Example of a Class class Bicycle { int cadence = 0; int speed = 0; int gear = 1; void changeCadence(int newValue) { cadence = newValue; } void changeGear(int newValue) { gear = newValue; } void speedUp(int increment) { speed = speed + increment; } void applyBrakes(int decrement) { speed = speed - decrement; } void printStates() { System.out.println("cadence:"+cadence+" speed:"+speed+" gear:"+gear); }

Inheritance

How to use inheritance Class MountainBike extends Bicycle { //properties of mountain bike }

Interface example public interface Bicycle { void changeCadence(int newValue); // wheel revolutions per minute void changeGear(int newValue); void speedUp(int increment); void applyBrakes(int decrement); }

How to implement the interface Class ACMEBicycle implements Bicycle { // remainder of this class implemented as before }

Sources  “Java OOP basics” 009/java_OOP_and_%20inheritance.pdf  The Java Tutorials. Trail: Learning the Java Language. Oct 19, 2009.