SlideShare uma empresa Scribd logo
1 de 34
Baixar para ler offline
Object Oriented Programming
    Introduction to OOP Concept
            Dr. Abzetdin ADAMOV
      Chair of Computer Engineering Department
                 aadamov@qu.edu.az

          http://ce.qu.edu.az/~aadamov
EVALUATION
• Midterm – 30%
• Compulsory Project – 20% (quiz – 70%;
  attendance – 30%)
• Final – 50%
• Total – 100 points

• Optional Project – 10 points (max) (Referat – in
  accordance to requirements, min 7 pages ,
  English + software implementation)

• Note: If you have requested Optional Project, it
  must be completed
References
ftp://store.qafqaz.local/student/AAdamov-ComputerSciences/Object-Oriented-
Programming/
1. Algorithms in Java: 1-4. Parts Robert Sedgewick
2. Algorithms in Java: Graph Algorithms: 5.Parts Robert Sedgewick
3. Data structures and other objects using JAVA Micheal Main
4. Enterprise J2ME: Devoliping mobile Java applications Michael Juntao Yuan
5. HTML-JAVA-CGI-VRML-SGML-Unleashed William Robert Stanek
6. JAVA ile Proglamlama: Sınıflar ve Arabirimler Mine Keskinkılıç
7. Java : How to program H.M. Deitel
8. Java Network Programming and Distributed Computing David Reilly
9. Java ile Temel Programlama Bora Güngören
10. Java kullanım kılavuzu
11. Murach's Java servlets and JSP Andrea Steelman Rafta
12. Understanding Object Oriented Programming with JAVA
12. Google Web Toolkit: GWT Java Ajax Programming
13. Core Servlets and Javaserver Pages: Core Technologies, Vol. 2 (2nd Edition)
14. Advanced JavaScript, 3rd Edition
15. Graphic Java 2, Volume 2, Swing (3rd Edition) (Sun Microsystems Press Java Series)
16. Java Examples in a Nutshell, 3rd Edition [ILLUSTRATED]
17. Java In A Nutshell, 5th Edition (Paperback)
18. Sams Teach Yourself Programming with Java in 24 Hours (4th Edition)
Computer History
• 1822 Charles Babbage Defference machine.
• 1942 ENIAC – the first electric machine
• 1945 John Von Neumann –
    – 1. shared programm technique
    – 2. condition control transfer
• 1949 John Von Neumann – fist computer lang. Short Code
• 1951 Grace Hopper – first compiler
• 1957 – IBM FORTRAN (FORmula TRANslate)
• 1959 – COBOL – (Common Business Oriented Language)
  language for Businessmen.
• 1958 – Algol – the root of Pascal, C and Java
• 1968 – Niklaus Wirth – Pascal – invented for education purposes
• 1972 – Dennis Ritchie - Bell Labs – C for new UNIX system
• 1983 – Bjarne Stroustroup – C++ OOP Concept
• 1990 – Sun Microsystems - Java
BİLGİSAYAR TARİHİ
Programming Approaches and
               Technologies
• Imperative programming
• Declarative programming
• Procedural programming
• Logical programming
• Functional programming


• Object Oriented Programming
• Agent Oriented Programming (Shoham, APSLA)
   • Agent-Oriented Programming, Systems, Languages and Applications

• Service Oriented Programming (Architecture) (WSDL, SSCL)
• Process Oriented Programming (SysML, PSL, BPEL, BPEL4WS)
   • Process Specification Language
A WAY OF VIEWING THE WORLD

                                                   Gardeners
              Friend
Me

                                                        Grower
Flora      Delivery Person       Flower Arranger


                                                   WholeSaler


                       Friend’s Florist
AGENT and COMMUNITIES
An object-oriented program is structured
as a community of interacting agents,
called Objects. Each object has a role to
play. Each object provides a service, or
perform an action, that is used by other
members of the community.
MESSAGES and METHODS
Action is initiated in object-oriented
programming by the transmission of a
message to an agent (an object)
responsible for the action. If the receiver
accepts the message, it accepts the
responsibility to carry out the indicated
action.
INDEPENDENCE and
        RESPOSIBILITIES
By discussing a problem in term of
Responsibilities, we increase the level of
abstraction. This permits greater
Independence between objects. The
entire collection of responsibilities
associated with an object is often termed
the Protocol.
CLASSES and INSTANCES
All objects are instances of a class. All
objects of a given class use the same
method in response to similar messages.
CLASS HIERARCHIES -
             INHERITANCE
 Human           A child class (or
 Female          subclass) will inherit
Shopkeeper
                 attributes from a
  Florist
                 parent class higher
  Flora
                 in the tree. An
                 Abstract Parent
                 Class is a class for
                 which there are no
                 direct instances.
Summary of Object-Oriented
                 Concepts
• Everything is an Object.
• Objects communicate by sending and receiving
  messages.
• Each object has its own memory, which consists of other
  objects.
• Every object is an instance of a class. A class simply
  represents a grouping of similar objects, such us
  integers or lists.
• The class is the repository for behavior associated with
  an object.
• Classes are organized into a singly rooted tree structure,
  called the inheritance hierarchy.
Introduction to Object Oriented
              Programming
• Abstraction
• Encapsulation
• Inheritance
Object Oriented Programming
                    Abstraction




• Radio is an object that was designed to hide its complexity.
• In object-oriented software, complexity is managed by using
abstraction.
• Abstraction is a process that involves identifying the crucial behavior
of an object and eliminating irrelevant and tedious details.
• Remember that the abstraction process is context sensitive.
Object Oriented Programming
               Abstraction




People come in all shapes, sizes, and colors. They have different
backgrounds, enjoy different hobbies, and have a multitude of
beliefs.
But perhaps, in terms of the payroll application, an employee is just
a name, a rank, and a serial number, while the other qualities are not
relevant to the application.
Object Oriented Programming
                 Encapsulation
                                      type
struct Kayitlar{
                                        LibRec =record
       char name[15];
                                          flag: char;
       char addres[15];
                                          name: string[20];
       int course;
                                          price: real;
       char comment[30];
                                          numb: integer;
}stud_info[5];
                                        end;
                                      var f: file of LibReci;
 Struct in C                           Record in Pascal

In both languages, a function can operate on more than one data type
and more than one function can operate on a single data type.
Because these languages do not explicitly tie together data and the
functions that operate on that data.
In contrast, object-oriented programming is based on
encapsulation. When an object’s state and behavior are kept
together, they are encapsulated.
Object Oriented Programming
                 Encapsulation
                              Information Hiding

• Encapsulation is often referred to as information
  hiding (“black box”).
• Information hiding is really the result of
  encapsulation,not a synonym for it.
• Encapsulation is also frequently confused with
  abstraction.
• Encapsulation is the mechanism by which the
  abstraction is implemented.(The radio, for instance, is an
  object that encapsulates many technologies that might not be understood
  clearly by most people who benefit from it.)
Object Oriented Programming
                  Inheritance
Inheritance is the ability to define a new class that inherits the
behaviors (and code) of an existing class. The new class is called a
child or derived class, while the original class is often referred to as
the parent or base class.
Inheritance is used to express “is-a” or “kind-of” relationships. A car
is a vehicle. A boat is a vehicle. A submarine is a vehicle.

The main concepts behind inheritance are extensibility and code
reuse.
 Composition
 In contrast to inheritance, there is also the notion of a “has-a” relationship.
 Naturally, a car has an engine, but it is not a kind of engine.
 Multiple Inheritance
 In this scenario, one class inherits from more than one base class.
Object Oriented Programming
                  Inheritance
class MotorVehicle class Car {           class Motorcycle {
{                    String make;
  String make;       String model;         String make;
  String model;      int year;             String model;
  int year;          int max_speed;        int year;
  int max_speed;     int weight            int max_speed;
  int weight         float price;          int weight
  float price;       int num_passengers;   float price;
  int                int num_wheels = 4;   int num_passengers;
num_passengers;      int num_doors;        int num_wheels = 2;
  int num_wheels; }
                                         }
}
Object Oriented Programming
                 Inheritance
class Motorcycle extends     class Car extends MotorVehicle {
MotorVehicle {                 int num_wheels = 4;
  int num_wheels = 2;          int num_doors;
}                            }




 class coupe extends Car {      class wagon extends Car {
   int num_doors = 2;             int num_doors = 5;
 }                              }
Object Oriented Programming
                Concept - Object
Real-world objects share two characteristics: They all
have state and behavior.
For each object that you see, ask yourself two questions: "What possible
states can this object be in?" and "What possible behavior can this object
perform?".

An object stores its state in fields (variables in some programming
languages) and exposes its behavior through methods (functions in some
programming languages).

Hiding internal state and requiring all
interaction to be performed through an
object's methods is known as
data encapsulation — a fundamental
principle of object-oriented programming.
Object Oriented Programming
                 Concept – Object
Consider a bicycle, for example:
A bicycle modeled as a software object.
By attributing state (current speed, current pedal cadence, and current gear)
and providing methods for changing that state, the object remains in control of
how the outside world is allowed to use it. For example, if the bicycle only has
6 gears, a method to change gears could reject any value that is less than 1
or greater than 6.

OOP provides a number of benefits, including:



1.   Modularity
2.   Information-hiding
3.   Code re-use
4.   Pluggability and debugging ease
Object Oriented Programming
                Concept – Class
In object-oriented terms, we say that your bicycle is an instance of the class
of objects known as bicycles. A class is the blueprint from which individual
objects are created.
Object Oriented Programming
                      Concept – Class
The Bicycle class:                    BicycleDemo class creates two separate Bicycle objects:
                                                            class BicycleDemo {
class Bicycle {                                                public static void main(String[] args) {
   int cadence = 0;
   int speed = 0;                                                   // Create two different
   int gear = 1;                                                    // Bicycle objects
                                                                    Bicycle bike1 = new Bicycle();
    void changeCadence(int newValue) {                              Bicycle bike2 = new Bicycle();
       cadence = newValue;
    }                                                               // Invoke methods on
    void changeGear(int newValue) {                                 // those objects
       gear = newValue;                                             bike1.changeCadence(50);
    }                                                               bike1.speedUp(10);
    void speedUp(int increment) {                                   bike1.changeGear(2);
       speed = speed + increment;                                   bike1.printStates();
    }                                                               bike2.changeCadence(50);
    void applyBrakes(int decrement) {                               bike2.speedUp(10);
       speed = speed - decrement;                                   bike2.changeGear(2);
    }                                                               bike2.changeCadence(40);
    void printStates() {                                            bike2.speedUp(10);
       System.out.println("cadence:" +                              bike2.changeGear(3);
          cadence + " speed:" + speed + " gear:" + gear);           bike2.printStates();
    }                                                           }
}                                                           }
Object Oriented Programming
              Concept – Inheritance
Object-oriented programming allows classes to inherit commonly used state
and behavior from other classes. In this example, Bicycle now becomes
the superclass of MountainBike, RoadBike, and TandemBike.
In the Java programming language, each class is allowed to have one direct
superclass, and each superclass has the potential for an unlimited number
of subclasses:
The syntax for creating a subclass is simple: use extend keyword
class MountainBike extends Bicycle {
// new fields and methods defining
// a mountain bike would go here
}
How JAVA Works?
In the Java programming language,
1. Source code is plain text files ending with the .java extension.
2. Source files are compiled into .class files javac compiler.
3. A .class file does not contain code that is native to your
    processor; it instead contains bytecodes — the machine
    language of the Java Virtual Machine1 (Java VM).
4. JVM then runs your application and communicate to system.
First JAVA Program

Because the Java VM is
available on many different
operating systems, the
same .class files are capable
of running on Microsoft
Windows, the Solaris™
Operating System (Solaris
OS), Linux, or Mac OS.
What Java Can Do?
•   Development Tools: The development tools provide everything you'll need for
    compiling, running, monitoring, debugging, and documenting your applications.
•   Application Programming Interface (API): The API provides a wide array of
    useful classes ready for use in your own applications. It spans everything from
    basic objects, to networking and security, to XML generation and database
    access, and more.
•   Deployment Technologies: The JDK software provides standard
    mechanisms such as the Java EE software for deploying your applications to
    end users.
•   User Interface Toolkits: The Swing and Java 2D toolkits make it possible to
    create sophisticated Graphical User Interfaces (GUIs).
•   Integration Libraries: Integration libraries such as the Java IDL (Interface
    Definition Language) API, JDBC™ API, Java Naming and Directory
    Interface™ (JNDI) API, Java RMI, and Java Remote Method Invocation over
    Internet Inter-ORB (Object Request Brokers) Protocol Technology (Java RMI-
    IIOP Technology) enable database access and manipulation of remote
    objects.
How Java Changes World?
•   Get started quickly: Especially for programmers already familiar with C or C++.
•   Write less code: Program written in the Java programming language can be four
    times smaller than the same program written in C++.
•   Write better code: The Java programming language encourages good coding
    practices, wide-ranging, easily extendible API let you reuse existing, tested code
    and introduce fewer bugs.
•   Develop programs more quickly: The Java programming language is simpler
    than C++, and as such, your development time could be up to twice as fast when
    writing in it.
•   Avoid platform dependencies: You can keep your program portable by avoiding
    the use of libraries written in other languages.
•   Write once, run anywhere: Because applications written in the Java
    programming language are compiled into machine-independent bytecodes, they
    run consistently on any Java platform.
•   Distribute software more easily: With Java Web Start software, users will be
    able to launch your applications with a single click of the mouse.
First JAVA Program

//Simple Stand-alone application
class HelloWorld {
  public static void main() {
    system.out.println(“Hello Worldn”);
  }
}
Checklist for Executing a Java
                Application

1. Create a user-defined class containing a main
   program; be sure that the signature of main
   method is correct
2. Check that the .java file has the same name as
   the name of the user-defined class
3. Compile the .java file to produce a
   corresponding .class file
4. Run the program using the Java intepreter
Why JAVA?
1.   Small Code           10.   Platform Independent
2.   General Interfaces   11.   Secure
3.   Simpler than…        12.   Fast
4.   Object-Oriented      13.   Encapsulated in JVM
5.   Network Savvy        14.   Different Technologies
6.   Interpreted          15.   Distributed Properties
7.   Robust
8.   Multithreaded
9.   Dynamic
QUESTIONS




http://ce.qu.edu.az/~aadamov

Mais conteúdo relacionado

Mais procurados

Object Oriented Programming in Python
Object Oriented Programming in PythonObject Oriented Programming in Python
Object Oriented Programming in PythonSujith Kumar
 
Object oriented programming concepts
Object oriented programming conceptsObject oriented programming concepts
Object oriented programming conceptsrahuld115
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++Muhammad Waqas
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of ConstructorsDhrumil Panchal
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingAmit Soni (CTFL)
 
Data Types & Variables in JAVA
Data Types & Variables in JAVAData Types & Variables in JAVA
Data Types & Variables in JAVAAnkita Totala
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops conceptsNilesh Dalvi
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT03062679929
 
Basics of JAVA programming
Basics of JAVA programmingBasics of JAVA programming
Basics of JAVA programmingElizabeth Thomas
 
Datatype in JavaScript
Datatype in JavaScriptDatatype in JavaScript
Datatype in JavaScriptRajat Saxena
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteTushar B Kute
 

Mais procurados (20)

Object Oriented Programming in Python
Object Oriented Programming in PythonObject Oriented Programming in Python
Object Oriented Programming in Python
 
Object oriented programming concepts
Object oriented programming conceptsObject oriented programming concepts
Object oriented programming concepts
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
 
Wrapper classes
Wrapper classesWrapper classes
Wrapper classes
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Data Types & Variables in JAVA
Data Types & Variables in JAVAData Types & Variables in JAVA
Data Types & Variables in JAVA
 
Python programming : Files
Python programming : FilesPython programming : Files
Python programming : Files
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops concepts
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
 
Object oriented programming in python
Object oriented programming in pythonObject oriented programming in python
Object oriented programming in python
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
Java program structure
Java program structureJava program structure
Java program structure
 
Basics of JAVA programming
Basics of JAVA programmingBasics of JAVA programming
Basics of JAVA programming
 
XML
XMLXML
XML
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Lecture 8 Library classes
Lecture 8 Library classesLecture 8 Library classes
Lecture 8 Library classes
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
 
Datatype in JavaScript
Datatype in JavaScriptDatatype in JavaScript
Datatype in JavaScript
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 

Destaque

Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).pptAlok Kumar
 
the Concept of Object-Oriented Programming
the Concept of Object-Oriented Programmingthe Concept of Object-Oriented Programming
the Concept of Object-Oriented ProgrammingAida Ramlan II
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingHüseyin Ergin
 
Object oriented programming concept
Object oriented programming conceptObject oriented programming concept
Object oriented programming conceptPina Parmar
 
11 constructors in derived classes
11 constructors in derived classes11 constructors in derived classes
11 constructors in derived classesDocent Education
 
Multi level hierarchy
Multi level hierarchyMulti level hierarchy
Multi level hierarchymyrajendra
 
2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers2CPP06 - Arrays and Pointers
2CPP06 - Arrays and PointersMichael Heron
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functionsMarlom46
 
Some Basic Concepts of Object Oriented Methodology
Some Basic Concepts of Object Oriented MethodologySome Basic Concepts of Object Oriented Methodology
Some Basic Concepts of Object Oriented MethodologyManoj Kumar
 
Friend functions
Friend functions Friend functions
Friend functions Megha Singh
 
Object oriented methodology & unified modeling language
Object oriented methodology & unified modeling languageObject oriented methodology & unified modeling language
Object oriented methodology & unified modeling languageIsmail El Gayar
 
[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member FunctionsMuhammad Hammad Waseem
 
Multiple Inheritance For C++
Multiple Inheritance For C++Multiple Inheritance For C++
Multiple Inheritance For C++elliando dias
 
Principles and advantages of oop ppt
Principles and advantages of oop pptPrinciples and advantages of oop ppt
Principles and advantages of oop pptdaxesh chauhan
 

Destaque (20)

Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).ppt
 
Oops ppt
Oops pptOops ppt
Oops ppt
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
History of OOP
History of OOPHistory of OOP
History of OOP
 
the Concept of Object-Oriented Programming
the Concept of Object-Oriented Programmingthe Concept of Object-Oriented Programming
the Concept of Object-Oriented Programming
 
C++ oop
C++ oopC++ oop
C++ oop
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Object oriented programming concept
Object oriented programming conceptObject oriented programming concept
Object oriented programming concept
 
11 constructors in derived classes
11 constructors in derived classes11 constructors in derived classes
11 constructors in derived classes
 
Multi level hierarchy
Multi level hierarchyMulti level hierarchy
Multi level hierarchy
 
2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functions
 
Some Basic Concepts of Object Oriented Methodology
Some Basic Concepts of Object Oriented MethodologySome Basic Concepts of Object Oriented Methodology
Some Basic Concepts of Object Oriented Methodology
 
Friend functions
Friend functions Friend functions
Friend functions
 
Object oriented methodology & unified modeling language
Object oriented methodology & unified modeling languageObject oriented methodology & unified modeling language
Object oriented methodology & unified modeling language
 
[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions
 
Templates
TemplatesTemplates
Templates
 
Multiple Inheritance For C++
Multiple Inheritance For C++Multiple Inheritance For C++
Multiple Inheritance For C++
 
Inheritance
InheritanceInheritance
Inheritance
 
Principles and advantages of oop ppt
Principles and advantages of oop pptPrinciples and advantages of oop ppt
Principles and advantages of oop ppt
 

Semelhante a Introduction to object oriented programming

introduction of Object oriented programming
introduction of Object oriented programmingintroduction of Object oriented programming
introduction of Object oriented programmingRiturajJain8
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP conceptsAhmed Farag
 
Class notes(week 2) on basic concepts of oop-2
Class notes(week 2) on basic concepts of oop-2Class notes(week 2) on basic concepts of oop-2
Class notes(week 2) on basic concepts of oop-2Kuntal Bhowmick
 
Class notes(week 2) on basic concepts of oop-2
Class notes(week 2) on basic concepts of oop-2Class notes(week 2) on basic concepts of oop-2
Class notes(week 2) on basic concepts of oop-2Kuntal Bhowmick
 
A Survey of Object Oriented Programming LanguagesMaya Hris.docx
A Survey of Object Oriented Programming LanguagesMaya Hris.docxA Survey of Object Oriented Programming LanguagesMaya Hris.docx
A Survey of Object Oriented Programming LanguagesMaya Hris.docxdaniahendric
 
Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)Nuzhat Memon
 
Introduction to oop and java fundamentals
Introduction to oop and java fundamentalsIntroduction to oop and java fundamentals
Introduction to oop and java fundamentalsAnsgarMary
 
Introduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John MulhallIntroduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John MulhallJohn Mulhall
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Languagedheva B
 
Object Oriented Programming Overview for the PeopleSoft Developer
Object Oriented Programming Overview for the PeopleSoft DeveloperObject Oriented Programming Overview for the PeopleSoft Developer
Object Oriented Programming Overview for the PeopleSoft DeveloperLee Greffin
 
M01_OO_Intro.ppt
M01_OO_Intro.pptM01_OO_Intro.ppt
M01_OO_Intro.pptRojaPogul1
 
Programming in Scala - Lecture One
Programming in Scala - Lecture OneProgramming in Scala - Lecture One
Programming in Scala - Lecture OneAngelo Corsaro
 
Md02 - Getting Started part-2
Md02 - Getting Started part-2Md02 - Getting Started part-2
Md02 - Getting Started part-2Rakesh Madugula
 
Chapter 1- Introduction.ppt
Chapter 1- Introduction.pptChapter 1- Introduction.ppt
Chapter 1- Introduction.pptTigistTilahun1
 
SE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTSE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTnikshaikh786
 
Java for android developers
Java for android developersJava for android developers
Java for android developersAly Abdelkareem
 
History of Object Orientation in OOP.ppt
History of Object Orientation in OOP.pptHistory of Object Orientation in OOP.ppt
History of Object Orientation in OOP.pptathar549116
 

Semelhante a Introduction to object oriented programming (20)

introduction of Object oriented programming
introduction of Object oriented programmingintroduction of Object oriented programming
introduction of Object oriented programming
 
Cs2305 programming paradigms lecturer notes
Cs2305   programming paradigms lecturer notesCs2305   programming paradigms lecturer notes
Cs2305 programming paradigms lecturer notes
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
 
Class notes(week 2) on basic concepts of oop-2
Class notes(week 2) on basic concepts of oop-2Class notes(week 2) on basic concepts of oop-2
Class notes(week 2) on basic concepts of oop-2
 
Class notes(week 2) on basic concepts of oop-2
Class notes(week 2) on basic concepts of oop-2Class notes(week 2) on basic concepts of oop-2
Class notes(week 2) on basic concepts of oop-2
 
General oop concept
General oop conceptGeneral oop concept
General oop concept
 
A Survey of Object Oriented Programming LanguagesMaya Hris.docx
A Survey of Object Oriented Programming LanguagesMaya Hris.docxA Survey of Object Oriented Programming LanguagesMaya Hris.docx
A Survey of Object Oriented Programming LanguagesMaya Hris.docx
 
Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)Std 12 computer chapter 6 object oriented concepts (part 1)
Std 12 computer chapter 6 object oriented concepts (part 1)
 
Introduction to oop and java fundamentals
Introduction to oop and java fundamentalsIntroduction to oop and java fundamentals
Introduction to oop and java fundamentals
 
Introduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John MulhallIntroduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John Mulhall
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Language
 
Object Oriented Programming Overview for the PeopleSoft Developer
Object Oriented Programming Overview for the PeopleSoft DeveloperObject Oriented Programming Overview for the PeopleSoft Developer
Object Oriented Programming Overview for the PeopleSoft Developer
 
OOP
OOPOOP
OOP
 
M01_OO_Intro.ppt
M01_OO_Intro.pptM01_OO_Intro.ppt
M01_OO_Intro.ppt
 
Programming in Scala - Lecture One
Programming in Scala - Lecture OneProgramming in Scala - Lecture One
Programming in Scala - Lecture One
 
Md02 - Getting Started part-2
Md02 - Getting Started part-2Md02 - Getting Started part-2
Md02 - Getting Started part-2
 
Chapter 1- Introduction.ppt
Chapter 1- Introduction.pptChapter 1- Introduction.ppt
Chapter 1- Introduction.ppt
 
SE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTSE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPT
 
Java for android developers
Java for android developersJava for android developers
Java for android developers
 
History of Object Orientation in OOP.ppt
History of Object Orientation in OOP.pptHistory of Object Orientation in OOP.ppt
History of Object Orientation in OOP.ppt
 

Mais de Abzetdin Adamov

Big Data and High Performance Computing
Big Data and High Performance ComputingBig Data and High Performance Computing
Big Data and High Performance ComputingAbzetdin Adamov
 
Understanding your Data - Data Analytics Lifecycle and Machine Learning
Understanding your Data - Data Analytics Lifecycle and Machine LearningUnderstanding your Data - Data Analytics Lifecycle and Machine Learning
Understanding your Data - Data Analytics Lifecycle and Machine LearningAbzetdin Adamov
 
Big Data Ecosystem for Data-Driven Decision Making
Big Data Ecosystem for Data-Driven Decision MakingBig Data Ecosystem for Data-Driven Decision Making
Big Data Ecosystem for Data-Driven Decision MakingAbzetdin Adamov
 
Latest Trends in Technology: BigData Analytics, Virtualization, Cloud Computi...
Latest Trends in Technology:BigData Analytics, Virtualization, Cloud Computi...Latest Trends in Technology:BigData Analytics, Virtualization, Cloud Computi...
Latest Trends in Technology: BigData Analytics, Virtualization, Cloud Computi...Abzetdin Adamov
 
Steps and Tips to Protect Yourself and your Private Information while Online....
Steps and Tips to Protect Yourself and your Private Information while Online....Steps and Tips to Protect Yourself and your Private Information while Online....
Steps and Tips to Protect Yourself and your Private Information while Online....Abzetdin Adamov
 
Technical, Legal and Political Issues of Combating Terrorism on the Internet.
Technical, Legal and Political Issues of Combating Terrorism on the Internet.Technical, Legal and Political Issues of Combating Terrorism on the Internet.
Technical, Legal and Political Issues of Combating Terrorism on the Internet.Abzetdin Adamov
 
Qafqaz university-inegrated-management-information-system
Qafqaz university-inegrated-management-information-systemQafqaz university-inegrated-management-information-system
Qafqaz university-inegrated-management-information-systemAbzetdin Adamov
 
Üniversite Bilgi Sistemi - Birimlerin İşbirliği Platformu
Üniversite Bilgi Sistemi - Birimlerin İşbirliği PlatformuÜniversite Bilgi Sistemi - Birimlerin İşbirliği Platformu
Üniversite Bilgi Sistemi - Birimlerin İşbirliği PlatformuAbzetdin Adamov
 
INFORMATION TECHNOLOGIES AS THE BASE OF THE BUSINESS PROCESS MANAGEMENT IMPLE...
INFORMATION TECHNOLOGIES AS THE BASE OF THE BUSINESS PROCESS MANAGEMENT IMPLE...INFORMATION TECHNOLOGIES AS THE BASE OF THE BUSINESS PROCESS MANAGEMENT IMPLE...
INFORMATION TECHNOLOGIES AS THE BASE OF THE BUSINESS PROCESS MANAGEMENT IMPLE...Abzetdin Adamov
 
e-Government Strategy. Government Transformation in Developing Countries of t...
e-Government Strategy. Government Transformation in Developing Countries of t...e-Government Strategy. Government Transformation in Developing Countries of t...
e-Government Strategy. Government Transformation in Developing Countries of t...Abzetdin Adamov
 
The Truth about Cloud Computing as new Paradigm in IT
The Truth about Cloud Computing  as new Paradigm in ITThe Truth about Cloud Computing  as new Paradigm in IT
The Truth about Cloud Computing as new Paradigm in ITAbzetdin Adamov
 
The Role of Business Process Management in Success of the e-Government Projec...
The Role of Business Process Management in Success of the e-Government Projec...The Role of Business Process Management in Success of the e-Government Projec...
The Role of Business Process Management in Success of the e-Government Projec...Abzetdin Adamov
 
University Management Information System
University Management Information SystemUniversity Management Information System
University Management Information SystemAbzetdin Adamov
 

Mais de Abzetdin Adamov (17)

Big Data and High Performance Computing
Big Data and High Performance ComputingBig Data and High Performance Computing
Big Data and High Performance Computing
 
Understanding your Data - Data Analytics Lifecycle and Machine Learning
Understanding your Data - Data Analytics Lifecycle and Machine LearningUnderstanding your Data - Data Analytics Lifecycle and Machine Learning
Understanding your Data - Data Analytics Lifecycle and Machine Learning
 
Big Data & Privacy
Big Data & PrivacyBig Data & Privacy
Big Data & Privacy
 
Big Data Ecosystem for Data-Driven Decision Making
Big Data Ecosystem for Data-Driven Decision MakingBig Data Ecosystem for Data-Driven Decision Making
Big Data Ecosystem for Data-Driven Decision Making
 
Latest Trends in Technology: BigData Analytics, Virtualization, Cloud Computi...
Latest Trends in Technology:BigData Analytics, Virtualization, Cloud Computi...Latest Trends in Technology:BigData Analytics, Virtualization, Cloud Computi...
Latest Trends in Technology: BigData Analytics, Virtualization, Cloud Computi...
 
Steps and Tips to Protect Yourself and your Private Information while Online....
Steps and Tips to Protect Yourself and your Private Information while Online....Steps and Tips to Protect Yourself and your Private Information while Online....
Steps and Tips to Protect Yourself and your Private Information while Online....
 
Technical, Legal and Political Issues of Combating Terrorism on the Internet.
Technical, Legal and Political Issues of Combating Terrorism on the Internet.Technical, Legal and Political Issues of Combating Terrorism on the Internet.
Technical, Legal and Political Issues of Combating Terrorism on the Internet.
 
Introduction to AJAX
Introduction to AJAXIntroduction to AJAX
Introduction to AJAX
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
 
Qafqaz university-inegrated-management-information-system
Qafqaz university-inegrated-management-information-systemQafqaz university-inegrated-management-information-system
Qafqaz university-inegrated-management-information-system
 
Grid Computing
Grid ComputingGrid Computing
Grid Computing
 
Üniversite Bilgi Sistemi - Birimlerin İşbirliği Platformu
Üniversite Bilgi Sistemi - Birimlerin İşbirliği PlatformuÜniversite Bilgi Sistemi - Birimlerin İşbirliği Platformu
Üniversite Bilgi Sistemi - Birimlerin İşbirliği Platformu
 
INFORMATION TECHNOLOGIES AS THE BASE OF THE BUSINESS PROCESS MANAGEMENT IMPLE...
INFORMATION TECHNOLOGIES AS THE BASE OF THE BUSINESS PROCESS MANAGEMENT IMPLE...INFORMATION TECHNOLOGIES AS THE BASE OF THE BUSINESS PROCESS MANAGEMENT IMPLE...
INFORMATION TECHNOLOGIES AS THE BASE OF THE BUSINESS PROCESS MANAGEMENT IMPLE...
 
e-Government Strategy. Government Transformation in Developing Countries of t...
e-Government Strategy. Government Transformation in Developing Countries of t...e-Government Strategy. Government Transformation in Developing Countries of t...
e-Government Strategy. Government Transformation in Developing Countries of t...
 
The Truth about Cloud Computing as new Paradigm in IT
The Truth about Cloud Computing  as new Paradigm in ITThe Truth about Cloud Computing  as new Paradigm in IT
The Truth about Cloud Computing as new Paradigm in IT
 
The Role of Business Process Management in Success of the e-Government Projec...
The Role of Business Process Management in Success of the e-Government Projec...The Role of Business Process Management in Success of the e-Government Projec...
The Role of Business Process Management in Success of the e-Government Projec...
 
University Management Information System
University Management Information SystemUniversity Management Information System
University Management Information System
 

Introduction to object oriented programming

  • 1. Object Oriented Programming Introduction to OOP Concept Dr. Abzetdin ADAMOV Chair of Computer Engineering Department aadamov@qu.edu.az http://ce.qu.edu.az/~aadamov
  • 2. EVALUATION • Midterm – 30% • Compulsory Project – 20% (quiz – 70%; attendance – 30%) • Final – 50% • Total – 100 points • Optional Project – 10 points (max) (Referat – in accordance to requirements, min 7 pages , English + software implementation) • Note: If you have requested Optional Project, it must be completed
  • 3. References ftp://store.qafqaz.local/student/AAdamov-ComputerSciences/Object-Oriented- Programming/ 1. Algorithms in Java: 1-4. Parts Robert Sedgewick 2. Algorithms in Java: Graph Algorithms: 5.Parts Robert Sedgewick 3. Data structures and other objects using JAVA Micheal Main 4. Enterprise J2ME: Devoliping mobile Java applications Michael Juntao Yuan 5. HTML-JAVA-CGI-VRML-SGML-Unleashed William Robert Stanek 6. JAVA ile Proglamlama: Sınıflar ve Arabirimler Mine Keskinkılıç 7. Java : How to program H.M. Deitel 8. Java Network Programming and Distributed Computing David Reilly 9. Java ile Temel Programlama Bora Güngören 10. Java kullanım kılavuzu 11. Murach's Java servlets and JSP Andrea Steelman Rafta 12. Understanding Object Oriented Programming with JAVA 12. Google Web Toolkit: GWT Java Ajax Programming 13. Core Servlets and Javaserver Pages: Core Technologies, Vol. 2 (2nd Edition) 14. Advanced JavaScript, 3rd Edition 15. Graphic Java 2, Volume 2, Swing (3rd Edition) (Sun Microsystems Press Java Series) 16. Java Examples in a Nutshell, 3rd Edition [ILLUSTRATED] 17. Java In A Nutshell, 5th Edition (Paperback) 18. Sams Teach Yourself Programming with Java in 24 Hours (4th Edition)
  • 4. Computer History • 1822 Charles Babbage Defference machine. • 1942 ENIAC – the first electric machine • 1945 John Von Neumann – – 1. shared programm technique – 2. condition control transfer • 1949 John Von Neumann – fist computer lang. Short Code • 1951 Grace Hopper – first compiler • 1957 – IBM FORTRAN (FORmula TRANslate) • 1959 – COBOL – (Common Business Oriented Language) language for Businessmen. • 1958 – Algol – the root of Pascal, C and Java • 1968 – Niklaus Wirth – Pascal – invented for education purposes • 1972 – Dennis Ritchie - Bell Labs – C for new UNIX system • 1983 – Bjarne Stroustroup – C++ OOP Concept • 1990 – Sun Microsystems - Java
  • 6. Programming Approaches and Technologies • Imperative programming • Declarative programming • Procedural programming • Logical programming • Functional programming • Object Oriented Programming • Agent Oriented Programming (Shoham, APSLA) • Agent-Oriented Programming, Systems, Languages and Applications • Service Oriented Programming (Architecture) (WSDL, SSCL) • Process Oriented Programming (SysML, PSL, BPEL, BPEL4WS) • Process Specification Language
  • 7. A WAY OF VIEWING THE WORLD Gardeners Friend Me Grower Flora Delivery Person Flower Arranger WholeSaler Friend’s Florist
  • 8. AGENT and COMMUNITIES An object-oriented program is structured as a community of interacting agents, called Objects. Each object has a role to play. Each object provides a service, or perform an action, that is used by other members of the community.
  • 9. MESSAGES and METHODS Action is initiated in object-oriented programming by the transmission of a message to an agent (an object) responsible for the action. If the receiver accepts the message, it accepts the responsibility to carry out the indicated action.
  • 10. INDEPENDENCE and RESPOSIBILITIES By discussing a problem in term of Responsibilities, we increase the level of abstraction. This permits greater Independence between objects. The entire collection of responsibilities associated with an object is often termed the Protocol.
  • 11. CLASSES and INSTANCES All objects are instances of a class. All objects of a given class use the same method in response to similar messages.
  • 12. CLASS HIERARCHIES - INHERITANCE Human A child class (or Female subclass) will inherit Shopkeeper attributes from a Florist parent class higher Flora in the tree. An Abstract Parent Class is a class for which there are no direct instances.
  • 13. Summary of Object-Oriented Concepts • Everything is an Object. • Objects communicate by sending and receiving messages. • Each object has its own memory, which consists of other objects. • Every object is an instance of a class. A class simply represents a grouping of similar objects, such us integers or lists. • The class is the repository for behavior associated with an object. • Classes are organized into a singly rooted tree structure, called the inheritance hierarchy.
  • 14. Introduction to Object Oriented Programming • Abstraction • Encapsulation • Inheritance
  • 15. Object Oriented Programming Abstraction • Radio is an object that was designed to hide its complexity. • In object-oriented software, complexity is managed by using abstraction. • Abstraction is a process that involves identifying the crucial behavior of an object and eliminating irrelevant and tedious details. • Remember that the abstraction process is context sensitive.
  • 16. Object Oriented Programming Abstraction People come in all shapes, sizes, and colors. They have different backgrounds, enjoy different hobbies, and have a multitude of beliefs. But perhaps, in terms of the payroll application, an employee is just a name, a rank, and a serial number, while the other qualities are not relevant to the application.
  • 17. Object Oriented Programming Encapsulation type struct Kayitlar{ LibRec =record char name[15]; flag: char; char addres[15]; name: string[20]; int course; price: real; char comment[30]; numb: integer; }stud_info[5]; end; var f: file of LibReci; Struct in C Record in Pascal In both languages, a function can operate on more than one data type and more than one function can operate on a single data type. Because these languages do not explicitly tie together data and the functions that operate on that data. In contrast, object-oriented programming is based on encapsulation. When an object’s state and behavior are kept together, they are encapsulated.
  • 18. Object Oriented Programming Encapsulation Information Hiding • Encapsulation is often referred to as information hiding (“black box”). • Information hiding is really the result of encapsulation,not a synonym for it. • Encapsulation is also frequently confused with abstraction. • Encapsulation is the mechanism by which the abstraction is implemented.(The radio, for instance, is an object that encapsulates many technologies that might not be understood clearly by most people who benefit from it.)
  • 19. Object Oriented Programming Inheritance Inheritance is the ability to define a new class that inherits the behaviors (and code) of an existing class. The new class is called a child or derived class, while the original class is often referred to as the parent or base class. Inheritance is used to express “is-a” or “kind-of” relationships. A car is a vehicle. A boat is a vehicle. A submarine is a vehicle. The main concepts behind inheritance are extensibility and code reuse. Composition In contrast to inheritance, there is also the notion of a “has-a” relationship. Naturally, a car has an engine, but it is not a kind of engine. Multiple Inheritance In this scenario, one class inherits from more than one base class.
  • 20. Object Oriented Programming Inheritance class MotorVehicle class Car { class Motorcycle { { String make; String make; String model; String make; String model; int year; String model; int year; int max_speed; int year; int max_speed; int weight int max_speed; int weight float price; int weight float price; int num_passengers; float price; int int num_wheels = 4; int num_passengers; num_passengers; int num_doors; int num_wheels = 2; int num_wheels; } } }
  • 21. Object Oriented Programming Inheritance class Motorcycle extends class Car extends MotorVehicle { MotorVehicle { int num_wheels = 4; int num_wheels = 2; int num_doors; } } class coupe extends Car { class wagon extends Car { int num_doors = 2; int num_doors = 5; } }
  • 22. Object Oriented Programming Concept - Object Real-world objects share two characteristics: They all have state and behavior. For each object that you see, ask yourself two questions: "What possible states can this object be in?" and "What possible behavior can this object perform?". An object stores its state in fields (variables in some programming languages) and exposes its behavior through methods (functions in some programming languages). Hiding internal state and requiring all interaction to be performed through an object's methods is known as data encapsulation — a fundamental principle of object-oriented programming.
  • 23. Object Oriented Programming Concept – Object Consider a bicycle, for example: A bicycle modeled as a software object. By attributing state (current speed, current pedal cadence, and current gear) and providing methods for changing that state, the object remains in control of how the outside world is allowed to use it. For example, if the bicycle only has 6 gears, a method to change gears could reject any value that is less than 1 or greater than 6. OOP provides a number of benefits, including: 1. Modularity 2. Information-hiding 3. Code re-use 4. Pluggability and debugging ease
  • 24. Object Oriented Programming Concept – Class In object-oriented terms, we say that your bicycle is an instance of the class of objects known as bicycles. A class is the blueprint from which individual objects are created.
  • 25. Object Oriented Programming Concept – Class The Bicycle class: BicycleDemo class creates two separate Bicycle objects: class BicycleDemo { class Bicycle { public static void main(String[] args) { int cadence = 0; int speed = 0; // Create two different int gear = 1; // Bicycle objects Bicycle bike1 = new Bicycle(); void changeCadence(int newValue) { Bicycle bike2 = new Bicycle(); cadence = newValue; } // Invoke methods on void changeGear(int newValue) { // those objects gear = newValue; bike1.changeCadence(50); } bike1.speedUp(10); void speedUp(int increment) { bike1.changeGear(2); speed = speed + increment; bike1.printStates(); } bike2.changeCadence(50); void applyBrakes(int decrement) { bike2.speedUp(10); speed = speed - decrement; bike2.changeGear(2); } bike2.changeCadence(40); void printStates() { bike2.speedUp(10); System.out.println("cadence:" + bike2.changeGear(3); cadence + " speed:" + speed + " gear:" + gear); bike2.printStates(); } } } }
  • 26. Object Oriented Programming Concept – Inheritance Object-oriented programming allows classes to inherit commonly used state and behavior from other classes. In this example, Bicycle now becomes the superclass of MountainBike, RoadBike, and TandemBike. In the Java programming language, each class is allowed to have one direct superclass, and each superclass has the potential for an unlimited number of subclasses: The syntax for creating a subclass is simple: use extend keyword class MountainBike extends Bicycle { // new fields and methods defining // a mountain bike would go here }
  • 27. How JAVA Works? In the Java programming language, 1. Source code is plain text files ending with the .java extension. 2. Source files are compiled into .class files javac compiler. 3. A .class file does not contain code that is native to your processor; it instead contains bytecodes — the machine language of the Java Virtual Machine1 (Java VM). 4. JVM then runs your application and communicate to system.
  • 28. First JAVA Program Because the Java VM is available on many different operating systems, the same .class files are capable of running on Microsoft Windows, the Solaris™ Operating System (Solaris OS), Linux, or Mac OS.
  • 29. What Java Can Do? • Development Tools: The development tools provide everything you'll need for compiling, running, monitoring, debugging, and documenting your applications. • Application Programming Interface (API): The API provides a wide array of useful classes ready for use in your own applications. It spans everything from basic objects, to networking and security, to XML generation and database access, and more. • Deployment Technologies: The JDK software provides standard mechanisms such as the Java EE software for deploying your applications to end users. • User Interface Toolkits: The Swing and Java 2D toolkits make it possible to create sophisticated Graphical User Interfaces (GUIs). • Integration Libraries: Integration libraries such as the Java IDL (Interface Definition Language) API, JDBC™ API, Java Naming and Directory Interface™ (JNDI) API, Java RMI, and Java Remote Method Invocation over Internet Inter-ORB (Object Request Brokers) Protocol Technology (Java RMI- IIOP Technology) enable database access and manipulation of remote objects.
  • 30. How Java Changes World? • Get started quickly: Especially for programmers already familiar with C or C++. • Write less code: Program written in the Java programming language can be four times smaller than the same program written in C++. • Write better code: The Java programming language encourages good coding practices, wide-ranging, easily extendible API let you reuse existing, tested code and introduce fewer bugs. • Develop programs more quickly: The Java programming language is simpler than C++, and as such, your development time could be up to twice as fast when writing in it. • Avoid platform dependencies: You can keep your program portable by avoiding the use of libraries written in other languages. • Write once, run anywhere: Because applications written in the Java programming language are compiled into machine-independent bytecodes, they run consistently on any Java platform. • Distribute software more easily: With Java Web Start software, users will be able to launch your applications with a single click of the mouse.
  • 31. First JAVA Program //Simple Stand-alone application class HelloWorld { public static void main() { system.out.println(“Hello Worldn”); } }
  • 32. Checklist for Executing a Java Application 1. Create a user-defined class containing a main program; be sure that the signature of main method is correct 2. Check that the .java file has the same name as the name of the user-defined class 3. Compile the .java file to produce a corresponding .class file 4. Run the program using the Java intepreter
  • 33. Why JAVA? 1. Small Code 10. Platform Independent 2. General Interfaces 11. Secure 3. Simpler than… 12. Fast 4. Object-Oriented 13. Encapsulated in JVM 5. Network Savvy 14. Different Technologies 6. Interpreted 15. Distributed Properties 7. Robust 8. Multithreaded 9. Dynamic