SlideShare a Scribd company logo
Java is an Object-Oriented Language In structured programming languages, methods define the structure of the programs, they are basic building blocks Data has secondary role, it is just something that is passed around. In object oriented languages, the data has the principal role Methods belong to the data, without the data, the method does not have any meaning (Except static methods) Data and methods together make up the object. OOP tries to model the real world. What does the real world look like?
Objects everywhere... Real world entities
World The world is  a set of things interacting with each other. OOP is more natural to humans, but less natural to computers Computers (usually) have a single thread of control, so objects take turns
Describing the world Describe a particular person Ayse has long blond hair, green eyes, is 1.63m tall, weighs 56Kg and studies computer engineering. Now lying down asleep. Mehmet studies electronics, has short black hair and brown eyes. He is 180cm and 75 kilos. Now running to class! Notice how all have specific values of name, height, weight, eye colour, state, …
Objects have identity... Our house The neighbour’s cat Hasan’s computer Merhababen Ayse My book Dombo the elephant
Objects have state... Red Lying Happy Hooked ill Broken
Objects have behavior…. Grrrrrrrr Vroemm Hello,  I am John Nice to  meet you da da …
Object Properties Identity State Behavior myLamp on off Object is an abstraction of a real world entity
Introduction to Objects An  object  represents something with which we can interact in a program An object provides a collection of services that we can tell it to perform for us The services are defined by methods in a  class  that defines the object A class represents a concept, and an object represents the embodiment of a class A class can be used to create multiple objects
Objects and Classes Bank   Account A class (the concept) John’s Bank Account Balance: $5,257 An object (the realization) Bill’s Bank Account Balance: $1,245,069 Mary’s Bank Account Balance: $16,833 Multiple objects from the same class
Java OOP terminology Class  - Category Properties/states Functionality/Services (examines/alters state) data methods object  - Individual/unique thing (an instance of a class) Particular value for each property/state & functionality of all members of class.
Java OOP Software Software System Set of objects  Which interact with each other One object will send a message to another object asking it to do a particular task. The first object does not need to know how the task is done (only how to request that it be done.) This corresponds to calling one of the  second object’s methods! Created (instantiated) from class definitions Person “ David” David: Say your name Ayse David
Abstraction An  abstraction  hides (or ignores) unnecessary details  denotes the essential properties of an object One of the fundamental ways in which we handle complexity Objects are abstractions of real world entities Programming goal: choose the right abstractions Abstraction A car consists of four wheels an engine, accumulator and brakes.
Multiple Abstractions A single thing can have multiple abstractions Example: a protein is… a sequence of amino acids a complicated 3D shape (a fold) a surface with “pockets” for ligands
Choosing Abstractions Abstractions can be about tangible things (a vehicle, a car, a map) or intangible things (a meeting, a route, a schedule) An example: Abstraction name: light Light’s wattage (i.e.,energy usage) Light can be on or off There are other possible properties (shape, color, socket size, etc.), but we have decided those are less essential The essential properties are determined by the problem
Object-Oriented Model methods data Object boundary
Example: Pencil location direction penDown home up down write
Encapsulation the data belonging to an object is hidden, so variables are  private methods are  public we use the public methods to change or access the private data No dependence on implementation location direction penDown home up down write public private
Programming Implications Encapsulation makes programming easier As long as the contract is the same, the client doesn’t care about the implementation In Java, as long as the method signatures are the same, the implementation details can be changed In other words, I can write my program using simple implementations; then, if necessary, I can replace some of the simple implementations with efficient implementations
Car Objects
Defining class Car What are the common attributes of cars? What are the common behaviors of cars?
Class Car  Car color speed power drive turn right turn left stop attributes operations class name
in Java Car String  color int  speed int  power drive() turnRight() turnLeft() stop() attributes or  instance variables methods class name
Java Syntax public class Car { // attribute declarations private String color; private int speed; private int power; // method declarations public void drive() {  // …. } public void turnRight() {  // …. } public void turnLeft() {  // …. } public void stop() {  // …. } } Car String  color int  speed int  power drive() turnRight() turnLeft() stop()
Class Pencil Pencil int location String direction home() up() down() write() attributes methods Name
Declaring objects A class can be used to  create  objects Objects are the instances of that class Car String  color int  speed int  power drive() turnRight() turnLeft() stop() new
Java's "Building Blocks" Data types  primitive constructs (e.g., integers, floating point numbers, characters) Class  A description of a set of objects used to create objects
Primitive Data There are exactly eight primitive data types in Java Four of them represent integers: byte ,  short ,  int ,  long Two of them represent floating point numbers: float ,  double One of them represents characters: char And one of them represents boolean values: boolean
Declaring object variables A class name can be used as a type to declare an  object reference variable Person ayse; An object reference variable holds the address of an object
Declaring Objects Class Person ayse; Person String name String birthDate int age getName() getAge … . ayse is of Class
Creating Objects We use the  new  operator to create an object ayse = new Person(); Creating an object is called  instantiation An object is an  instance  of a particular class We can combine declaration and creation: ayse Class Object instance of refers to Person ayse = new Person(); is of Class Person String name String birthDate int age getName() getAge … .
Declaring and Creating Objects Class karanfil = new Flower(); Flower karanfil; Flower int age int length int weight getAge() getLength() … . Object instance of refers to karanfil is of Class
Basic approach Define class Declare objects Create objects Use objects
Using objects The way you work with objects is to send them messages Most statements using objects have the following structure object.method for example:  thisPerson.setAge(24); This means the object whose name is  thisPerson is sent the message  setAge() along with the "value" 24 The effect of this is to set the person's age to be 24 years old
Example ayse Class Object instance of refers to is of Class ayse = new Person(); Person ayse; ayse.setName( “Ayse Engin“) ; ayse.setAge(24); Person String name String birthDate int age setName(String name) setAge(int age) getName() … . Ayse Engin 24

More Related Content

PPTX
Object Oriented Concept
D Nayanathara
 
PDF
Object Oriented Programming Lecture Notes
FellowBuddy.com
 
PPSX
Class as the basis of all computation
abhijeetkumarkar422
 
PDF
CLASS & OBJECT IN JAVA
Riaj Uddin Mahi
 
PPT
Oop java
Minal Maniar
 
PDF
Lecture 1 - Objects and classes
Syed Afaq Shah MACS CP
 
PPTX
Java
Shridhar Ramesh
 
Object Oriented Concept
D Nayanathara
 
Object Oriented Programming Lecture Notes
FellowBuddy.com
 
Class as the basis of all computation
abhijeetkumarkar422
 
CLASS & OBJECT IN JAVA
Riaj Uddin Mahi
 
Oop java
Minal Maniar
 
Lecture 1 - Objects and classes
Syed Afaq Shah MACS CP
 

What's hot (20)

PPTX
Introduction to OOP concepts
Ahmed Farag
 
PPT
Object oriented programming (oop) cs304 power point slides lecture 01
Adil Kakakhel
 
PPTX
Static keyword ppt
Vinod Kumar
 
PPTX
OOPS in Java
Zeeshan Khan
 
PPTX
Classes and objects
Anil Kumar
 
PPT
Lect 1-class and object
Fajar Baskoro
 
PDF
Object Oriented Paradigm
Hüseyin Ergin
 
PPTX
Object oriented architecture in erp
Preyanshu Saini
 
PPTX
Classes objects in java
Madishetty Prathibha
 
PPT
Oops Concept Java
Kamlesh Singh
 
PPTX
Oop c++class(final).ppt
Alok Kumar
 
PDF
Java Programming Paradigms Chapter 1
Sakthi Durai
 
PDF
Java data types, variables and jvm
Madishetty Prathibha
 
PDF
Introduction to object oriented programming
Abzetdin Adamov
 
DOC
C# by Zaheer Abbas Aghani
Information Technology Center
 
PPT
Classes&objects
M Vishnuvardhan Reddy
 
PPTX
Java basics and java variables
Pushpendra Tyagi
 
PPT
Oop Presentation
Ghaffar Khan
 
PPTX
Lecture 1 oop
Tony Apreku
 
PPT
Object-oriented concepts
BG Java EE Course
 
Introduction to OOP concepts
Ahmed Farag
 
Object oriented programming (oop) cs304 power point slides lecture 01
Adil Kakakhel
 
Static keyword ppt
Vinod Kumar
 
OOPS in Java
Zeeshan Khan
 
Classes and objects
Anil Kumar
 
Lect 1-class and object
Fajar Baskoro
 
Object Oriented Paradigm
Hüseyin Ergin
 
Object oriented architecture in erp
Preyanshu Saini
 
Classes objects in java
Madishetty Prathibha
 
Oops Concept Java
Kamlesh Singh
 
Oop c++class(final).ppt
Alok Kumar
 
Java Programming Paradigms Chapter 1
Sakthi Durai
 
Java data types, variables and jvm
Madishetty Prathibha
 
Introduction to object oriented programming
Abzetdin Adamov
 
C# by Zaheer Abbas Aghani
Information Technology Center
 
Classes&objects
M Vishnuvardhan Reddy
 
Java basics and java variables
Pushpendra Tyagi
 
Oop Presentation
Ghaffar Khan
 
Lecture 1 oop
Tony Apreku
 
Object-oriented concepts
BG Java EE Course
 
Ad

Similar to Java is an Object-Oriented Language (20)

PPTX
UNIT I OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
mohanrajm63
 
PDF
CS8392-OOPS-Printed-Notes-All-Units.pdf for students
KaviShetty
 
PDF
Java Progamming Paradigms, OOPS Concept, Introduction to Java, Structure of J...
Sakthi Durai
 
PDF
Class notes(week 2) on basic concepts of oop-2
Kuntal Bhowmick
 
DOCX
Class notes(week 2) on basic concepts of oop-2
Kuntal Bhowmick
 
PPT
Md02 - Getting Started part-2
Rakesh Madugula
 
PPTX
Android Training (Java Review)
Khaled Anaqwa
 
PDF
Oops concepts
ACCESS Health Digital
 
PDF
JAVA-PPT'S.pdf
AnmolVerma363503
 
PPTX
bbbnnjxhxshjsjskshsjsjshssddhjddjdjddhgd
zoobiarana76
 
PPTX
Object Oriented Programming Tutorial.pptx
ethiouniverse
 
DOCX
Object Oriented Programming All Unit Notes
BalamuruganV28
 
PPTX
Java Object-Oriented Programming Conecpts(Real-Time) Examples
Shridhar Ramesh
 
PPTX
JAVA-PPT'S-complete-chrome.pptx
KunalYadav65140
 
PPTX
JAVA-PPT'S.pptx
RaazIndia
 
DOCX
javaopps concepts
Nikhil Agrawal
 
PPTX
Java Programming - UNIT - 1, Basics OOPS, Differences
PradeepT42
 
PDF
Complete Java Course
Lhouceine OUHAMZA
 
PDF
M.c.a. (sem iv)- java programming
Praveen Chowdary
 
PDF
Programming Laboratory Unit 1.pdf
swapnilslide2019
 
UNIT I OOP AND JAVA FUNDAMENTALS CONSTRUCTOR
mohanrajm63
 
CS8392-OOPS-Printed-Notes-All-Units.pdf for students
KaviShetty
 
Java Progamming Paradigms, OOPS Concept, Introduction to Java, Structure of J...
Sakthi Durai
 
Class notes(week 2) on basic concepts of oop-2
Kuntal Bhowmick
 
Class notes(week 2) on basic concepts of oop-2
Kuntal Bhowmick
 
Md02 - Getting Started part-2
Rakesh Madugula
 
Android Training (Java Review)
Khaled Anaqwa
 
Oops concepts
ACCESS Health Digital
 
JAVA-PPT'S.pdf
AnmolVerma363503
 
bbbnnjxhxshjsjskshsjsjshssddhjddjdjddhgd
zoobiarana76
 
Object Oriented Programming Tutorial.pptx
ethiouniverse
 
Object Oriented Programming All Unit Notes
BalamuruganV28
 
Java Object-Oriented Programming Conecpts(Real-Time) Examples
Shridhar Ramesh
 
JAVA-PPT'S-complete-chrome.pptx
KunalYadav65140
 
JAVA-PPT'S.pptx
RaazIndia
 
javaopps concepts
Nikhil Agrawal
 
Java Programming - UNIT - 1, Basics OOPS, Differences
PradeepT42
 
Complete Java Course
Lhouceine OUHAMZA
 
M.c.a. (sem iv)- java programming
Praveen Chowdary
 
Programming Laboratory Unit 1.pdf
swapnilslide2019
 
Ad

More from ale8819 (11)

PPT
Disco Duro
ale8819
 
PPT
Fuentes De Campos Magnéticos
ale8819
 
PPT
AWT- JAVA
ale8819
 
PPT
Manejo de eventos
ale8819
 
PPT
Appleofdiscord
ale8819
 
DOC
Qubits
ale8819
 
PPT
Magnetismo
ale8819
 
PPT
JAVA
ale8819
 
PPT
Excepciones
ale8819
 
PPT
programacion orientada a objetos
ale8819
 
PPT
pci
ale8819
 
Disco Duro
ale8819
 
Fuentes De Campos Magnéticos
ale8819
 
AWT- JAVA
ale8819
 
Manejo de eventos
ale8819
 
Appleofdiscord
ale8819
 
Qubits
ale8819
 
Magnetismo
ale8819
 
JAVA
ale8819
 
Excepciones
ale8819
 
programacion orientada a objetos
ale8819
 
pci
ale8819
 

Recently uploaded (20)

PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PDF
Software Development Company | KodekX
KodekX
 
PPT
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
Architecture of the Future (09152021)
EdwardMeyman
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PDF
Software Development Methodologies in 2025
KodekX
 
PDF
This slide provides an overview Technology
mineshkharadi333
 
PPTX
Coupa-Overview _Assumptions presentation
annapureddyn
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PPTX
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
Software Development Company | KodekX
KodekX
 
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
Architecture of the Future (09152021)
EdwardMeyman
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
Software Development Methodologies in 2025
KodekX
 
This slide provides an overview Technology
mineshkharadi333
 
Coupa-Overview _Assumptions presentation
annapureddyn
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 

Java is an Object-Oriented Language

  • 1. Java is an Object-Oriented Language In structured programming languages, methods define the structure of the programs, they are basic building blocks Data has secondary role, it is just something that is passed around. In object oriented languages, the data has the principal role Methods belong to the data, without the data, the method does not have any meaning (Except static methods) Data and methods together make up the object. OOP tries to model the real world. What does the real world look like?
  • 2. Objects everywhere... Real world entities
  • 3. World The world is a set of things interacting with each other. OOP is more natural to humans, but less natural to computers Computers (usually) have a single thread of control, so objects take turns
  • 4. Describing the world Describe a particular person Ayse has long blond hair, green eyes, is 1.63m tall, weighs 56Kg and studies computer engineering. Now lying down asleep. Mehmet studies electronics, has short black hair and brown eyes. He is 180cm and 75 kilos. Now running to class! Notice how all have specific values of name, height, weight, eye colour, state, …
  • 5. Objects have identity... Our house The neighbour’s cat Hasan’s computer Merhababen Ayse My book Dombo the elephant
  • 6. Objects have state... Red Lying Happy Hooked ill Broken
  • 7. Objects have behavior…. Grrrrrrrr Vroemm Hello, I am John Nice to meet you da da …
  • 8. Object Properties Identity State Behavior myLamp on off Object is an abstraction of a real world entity
  • 9. Introduction to Objects An object represents something with which we can interact in a program An object provides a collection of services that we can tell it to perform for us The services are defined by methods in a class that defines the object A class represents a concept, and an object represents the embodiment of a class A class can be used to create multiple objects
  • 10. Objects and Classes Bank Account A class (the concept) John’s Bank Account Balance: $5,257 An object (the realization) Bill’s Bank Account Balance: $1,245,069 Mary’s Bank Account Balance: $16,833 Multiple objects from the same class
  • 11. Java OOP terminology Class - Category Properties/states Functionality/Services (examines/alters state) data methods object - Individual/unique thing (an instance of a class) Particular value for each property/state & functionality of all members of class.
  • 12. Java OOP Software Software System Set of objects Which interact with each other One object will send a message to another object asking it to do a particular task. The first object does not need to know how the task is done (only how to request that it be done.) This corresponds to calling one of the second object’s methods! Created (instantiated) from class definitions Person “ David” David: Say your name Ayse David
  • 13. Abstraction An abstraction hides (or ignores) unnecessary details denotes the essential properties of an object One of the fundamental ways in which we handle complexity Objects are abstractions of real world entities Programming goal: choose the right abstractions Abstraction A car consists of four wheels an engine, accumulator and brakes.
  • 14. Multiple Abstractions A single thing can have multiple abstractions Example: a protein is… a sequence of amino acids a complicated 3D shape (a fold) a surface with “pockets” for ligands
  • 15. Choosing Abstractions Abstractions can be about tangible things (a vehicle, a car, a map) or intangible things (a meeting, a route, a schedule) An example: Abstraction name: light Light’s wattage (i.e.,energy usage) Light can be on or off There are other possible properties (shape, color, socket size, etc.), but we have decided those are less essential The essential properties are determined by the problem
  • 16. Object-Oriented Model methods data Object boundary
  • 17. Example: Pencil location direction penDown home up down write
  • 18. Encapsulation the data belonging to an object is hidden, so variables are private methods are public we use the public methods to change or access the private data No dependence on implementation location direction penDown home up down write public private
  • 19. Programming Implications Encapsulation makes programming easier As long as the contract is the same, the client doesn’t care about the implementation In Java, as long as the method signatures are the same, the implementation details can be changed In other words, I can write my program using simple implementations; then, if necessary, I can replace some of the simple implementations with efficient implementations
  • 21. Defining class Car What are the common attributes of cars? What are the common behaviors of cars?
  • 22. Class Car Car color speed power drive turn right turn left stop attributes operations class name
  • 23. in Java Car String color int speed int power drive() turnRight() turnLeft() stop() attributes or instance variables methods class name
  • 24. Java Syntax public class Car { // attribute declarations private String color; private int speed; private int power; // method declarations public void drive() { // …. } public void turnRight() { // …. } public void turnLeft() { // …. } public void stop() { // …. } } Car String color int speed int power drive() turnRight() turnLeft() stop()
  • 25. Class Pencil Pencil int location String direction home() up() down() write() attributes methods Name
  • 26. Declaring objects A class can be used to create objects Objects are the instances of that class Car String color int speed int power drive() turnRight() turnLeft() stop() new
  • 27. Java's "Building Blocks" Data types primitive constructs (e.g., integers, floating point numbers, characters) Class A description of a set of objects used to create objects
  • 28. Primitive Data There are exactly eight primitive data types in Java Four of them represent integers: byte , short , int , long Two of them represent floating point numbers: float , double One of them represents characters: char And one of them represents boolean values: boolean
  • 29. Declaring object variables A class name can be used as a type to declare an object reference variable Person ayse; An object reference variable holds the address of an object
  • 30. Declaring Objects Class Person ayse; Person String name String birthDate int age getName() getAge … . ayse is of Class
  • 31. Creating Objects We use the new operator to create an object ayse = new Person(); Creating an object is called instantiation An object is an instance of a particular class We can combine declaration and creation: ayse Class Object instance of refers to Person ayse = new Person(); is of Class Person String name String birthDate int age getName() getAge … .
  • 32. Declaring and Creating Objects Class karanfil = new Flower(); Flower karanfil; Flower int age int length int weight getAge() getLength() … . Object instance of refers to karanfil is of Class
  • 33. Basic approach Define class Declare objects Create objects Use objects
  • 34. Using objects The way you work with objects is to send them messages Most statements using objects have the following structure object.method for example: thisPerson.setAge(24); This means the object whose name is thisPerson is sent the message setAge() along with the "value" 24 The effect of this is to set the person's age to be 24 years old
  • 35. Example ayse Class Object instance of refers to is of Class ayse = new Person(); Person ayse; ayse.setName( “Ayse Engin“) ; ayse.setAge(24); Person String name String birthDate int age setName(String name) setAge(int age) getName() … . Ayse Engin 24