SlideShare a Scribd company logo
Endina Putri Purwandari, M.Kom
OOP Concepts :
Illustration Sending Flowers to a Friend
 Suppose I wish to send flowers to a friend, Sally, who
lives in a city many miles away.
 ◦What should I do?
Agents and Communities
 Solution: Find an appropriate agent, namely Flora, and
pass to her a message containing my request
 It is the responsibility of Flora to satisfy my request
 There is some method–some algorithm or some set of
operations –used to satisfy my request
 This information, i.e., details, is usually hidden from my
inspection.
The community of agents helping me
An observation
 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 performs an action, that
is used by other members of the community.
Messages and Methods
 Action is initiated in OOP by the transmission of a
message to an agent (an object) responsible for the
action.
 The message encodes the request for an action and is
accompanied by any additional information (arguments)
needed to carry out the request.
 The receivers the object to whom the message is sent. If
the receiver accepts the message, it accepts the
responsibility to carry out the indicated action.
 In response to a message, the receiver will perform some
method to satisfy the request.
Classes and Instances
 We can use the term Florist to represent the category (or
class) of all florists.
 I am able to make certain assumptions because I have
information about florists in general, and I expect that
Flora, being an instance of this category, will fit the general
pattern.
 All objects are instances of a class
 The method invoked by an object in response to a
message is determined by the class of the receiver
 All objects of a given class use the same method in
response to similar messages.
 The principle that knowledge of a more general category
is also applicable to a more specific category is called
inheritance.
 The class Floristwill inherit attributes of the class (or
category) Shopkeeper.
 Classes can be organized into a hierarchical inheritance
structure.
 A child class(or subclass) will inherit attributes from a
parent class higher in the hierarchy. An abstract parent
class is a class for which there are no direct instances; it is
used only to create subclasses.
 That Liz and my florist Flora will respond to my message
by different methods is an example of one form of
Polymorphism.
 ◦That I do not, need not, know exactly what method
Flora will use to honor my message is an example of
information hiding.
Java: Good and Bad
 Good:
 Platform independent execution
 Platform independent binary data (files etc)
 Robust
 Does not allow operator overloading. Some people regard this as a
limitation. Others think operator overloading is not a good idea anyway!
 Comes with a huge class library which allow:
 File input / output
 Graphics
 Event trapping / handling
 3D modelling
 Bad:
 Syntax is adopted from C. This means that some control structures are
primitive and unstructured
 Graphics library still provides problems across different platforms
OO Characteristics
1. Everything is an object.
2. A program is a bunch of objects telling each other what
to do by sending messages.
3. Each object has its own memory made up of other
objects.
4. Every object has a type.
5. All objects of a particular type can receive the same
messages
 Everything is an object.
 Think of an object as a fancy variable; it stores data, but
you can “make requests” to that object, asking it to
perform operations on itself. In theory, you can take any
conceptual component in the problem you’re trying to
solve (dogs, buildings, services, etc.) and represent it as
an object in your program.
 A program is a bunch of objects telling each other
what to do by sending messages.
 To make a request of an object, you “send a message” to
that object. More concretely, you can think of a message as
a request to call a method that belongs to a particular
object.
 Each object has its own memory made up of other
objects.
 Put another way, you create a new kind of object by making
a package containing existing objects. Thus, you can build
complexity into a program while hiding it behind the
simplicity of objects.
 Every object has a type.
 Using the parlance, each object is an instance of a class, in which
“class” is synonymous with “type.” The most important
distinguishing characteristic of a class is: “What messages can
you send to it?”
 All objects of a particular type can receive the same
messages.
 This is actually a loaded statement, as you will see later. Because
an object of type “circle” is also an object of type “shape,” a circle
is guaranteed to accept shape messages. This means you can
write code that talks to shapes and automatically handle
anything that fits the description of a shape. This
substitutability is one of the powerful concepts in OOP.
To be OO or not to be OO?
 There are two basic paradigms for designing algorithms:
 Non Object Oriented:
 Focus is on the steps required to perform the task.
 The design of the steps lead to the types of data structures
that will be required.
 Object Oriented:
 Focus is on the entities required. i.e. what are the things
that need to be represented in the algorithm and:
 what functionality will each thing require.
 how these things will communicate with each other.
 ◦Each entity will be represented as an object.
Small Program Example
Creating, Compiling, and Running a Java
Program
 The Java code on the previous slide is entered into a text file
using a text editor
 The name of the .java file MUST be EXACTLY the same as the
name of the class (ie. Welcome1.java)
 The .java file is then compiled into byte code:
 The command would be: javac Welcome1.java
 If the program contained errors then error messages are
displayed
 Otherwise the byte code is produced
 The byte code is stored in a file called Welcome1.class
 The program can then be executed using the command:
java Welcome1
The main() Method
 A Java program starts by executing the main() method
 The main() method provides the starting point for the
program
 Within the main() method:
 Other methods will be invoked
 Objects will be created and
 Methods within those objects invoked
 Simple
Simple Application
Application Structure and Elements
Constructors
 Classes have a special method called a constructor that is
called when a class instance is created.
 ◦The class constructor always has the same name as the
class and no return type.
 ◦If you do not write your own constructor, the compiler
adds an empty constructor, which calls the no-arguments
constructor of its parent class.
 ◦The empty constructor is called the default constructor.
 ◦The default constructor initializes all non-initialized
fields and variables to zero.
Introduction to Methods
 A method consists of
 A header
 A body
 The header consists of
 The type of the method
 The name of the method
 The parameters to the method
 The body consists of a sequence of Java statements
encapsulated by { and }
Methods
 A method can be called only for an object, and that
object must be able to perform that method call.
 Call a method:
 objectName.methodName(arg1, arg2, arg3);
 The act of calling a method is commonly referred to as
sending a message to an object
 boolean flag() { return true; }
 float naturalLogBase() { return 2.718f; }
 void nothing() { return; }
 void nothing2() {}
Fields
Fields
Simple HelloWorld!
Applet
Applet (Sample Code)
Run the Applet
Object Oriented Technology
 Object-oriented design (OOD)
 ◦Models real-world objects
 ◦Models communication among objects
 ◦Encapsulates attributes and operations (behaviors)
 Information hiding
 Communication through well-defined interfaces
 Object-oriented language
 ◦Programming in object-oriented languages is called
object-oriented programming (OOP)
 ◦Java
Introduction to Class Diagram A class diagram shows the existence of classes and their
relationships in the logical view of a system
Control Structures Two basic types of control structures:
 Selection: Given one or more possible choices: choose which
section (if any) of an algorithm to execute.
 Iteration: Repeat a section of an algorithm provided required
conditions are met. Also known as looping.
 Selection Control:
 The If−Then_Else statement. Provides up to two possible
alternatives.
 The Case statement. Provides any number of possible
alternatives.
 Repetition Control:
 while
 do…while
 for
Exercise
If-Then-Else: Java Implementation
Conditional Operator (? : )
 Java’s only ternary operator (takes three operands) ? : and
its three operands form a conditional expression
 Entire conditional expression evaluates to the second
operand if the first operand is true
 Entire conditional expression evaluates to the third
operand if the first operand is false
Conditional Operator (? : )
switch Multiple Selection Statement
 When the expression matches a case, the statements in
the case are executed until:
 A break statement is encountered or
 The end of the switch statement is encountered
 The default clause is optional
 If the default clause is supplied then it is executed if the
switch expression does not match any of the case
constants
switch Multiple Selection Statement
Mistakes are easy with switch
Corrected Version
break and continue Statement
break Statement
continue Statement
Object Creation
Primitive vs Reference Variables
Initialization
Constructors
The Constructor
The Java String Class
Rules for Identifiers
Guidelines for Identifers
2.oop concept
2.oop concept

More Related Content

What's hot

Object oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh UpadhyayObject oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh Upadhyay
Saurabh Upadhyay
 
Basic concept of Object Oriented Programming
Basic concept of Object Oriented Programming Basic concept of Object Oriented Programming
Basic concept of Object Oriented Programming
Prognoz Technologies Pvt. Ltd.
 
C# interview quesions
C# interview quesionsC# interview quesions
C# interview quesions
Shashwat Shriparv
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answers
Madhavendra Dutt
 
EEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerEEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answer
Jeba Moses
 
object oriented programming using c++
 object oriented programming using c++ object oriented programming using c++
object oriented programming using c++
fasalsial1fasalsial1
 
L2 datatypes and variables
L2 datatypes and variablesL2 datatypes and variables
L2 datatypes and variablesRavi_Kant_Sahu
 
Top 20 c# interview Question and answers
Top 20 c# interview Question and answersTop 20 c# interview Question and answers
Top 20 c# interview Question and answers
w3asp dotnet
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
Madishetty Prathibha
 
Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes
Uzair Salman
 
OOP Principles
OOP PrinciplesOOP Principles
OOP Principles
Upender Upr
 
Classes cpp intro thomson bayan college
Classes cpp  intro thomson bayan collegeClasses cpp  intro thomson bayan college
Classes cpp intro thomson bayan college
ahmed hmed
 
Ap Power Point Chpt4
Ap Power Point Chpt4Ap Power Point Chpt4
Ap Power Point Chpt4dplunkett
 
2 lesson 2 object oriented programming in c++
2 lesson 2 object oriented programming in c++2 lesson 2 object oriented programming in c++
2 lesson 2 object oriented programming in c++Jeff TUYISHIME
 
C# interview questions
C# interview questionsC# interview questions
C# interview questions
Chetan Chaudhari
 

What's hot (20)

Object oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh UpadhyayObject oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh Upadhyay
 
Basic concept of Object Oriented Programming
Basic concept of Object Oriented Programming Basic concept of Object Oriented Programming
Basic concept of Object Oriented Programming
 
C# interview quesions
C# interview quesionsC# interview quesions
C# interview quesions
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answers
 
EEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerEEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answer
 
object oriented programming using c++
 object oriented programming using c++ object oriented programming using c++
object oriented programming using c++
 
Oops
OopsOops
Oops
 
Generics
GenericsGenerics
Generics
 
L2 datatypes and variables
L2 datatypes and variablesL2 datatypes and variables
L2 datatypes and variables
 
Top 20 c# interview Question and answers
Top 20 c# interview Question and answersTop 20 c# interview Question and answers
Top 20 c# interview Question and answers
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes Object Oriented Programming using JAVA Notes
Object Oriented Programming using JAVA Notes
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
OOP Principles
OOP PrinciplesOOP Principles
OOP Principles
 
Classes cpp intro thomson bayan college
Classes cpp  intro thomson bayan collegeClasses cpp  intro thomson bayan college
Classes cpp intro thomson bayan college
 
Oops Concept Java
Oops Concept JavaOops Concept Java
Oops Concept Java
 
Wrapper classes
Wrapper classesWrapper classes
Wrapper classes
 
Ap Power Point Chpt4
Ap Power Point Chpt4Ap Power Point Chpt4
Ap Power Point Chpt4
 
2 lesson 2 object oriented programming in c++
2 lesson 2 object oriented programming in c++2 lesson 2 object oriented programming in c++
2 lesson 2 object oriented programming in c++
 
C# interview questions
C# interview questionsC# interview questions
C# interview questions
 

Viewers also liked

5 mis-sustainable development
5 mis-sustainable development5 mis-sustainable development
5 mis-sustainable developmentRobbie AkaChopa
 
White Paper_RIBER_Kunal
White Paper_RIBER_KunalWhite Paper_RIBER_Kunal
White Paper_RIBER_Kunalkunalparekh27
 
Un trago muy original
Un trago muy originalUn trago muy original
Un trago muy originalrobmolero
 
Bahan ajar ekonomi kredit
Bahan ajar ekonomi kreditBahan ajar ekonomi kredit
Bahan ajar ekonomi kredit
Robbie AkaChopa
 
Snmptn 2012 tbs [akachopa.com]
Snmptn 2012 tbs [akachopa.com]Snmptn 2012 tbs [akachopa.com]
Snmptn 2012 tbs [akachopa.com]Robbie AkaChopa
 
Snmptn 2012 ipa [akachopa.com]
Snmptn 2012 ipa [akachopa.com]Snmptn 2012 ipa [akachopa.com]
Snmptn 2012 ipa [akachopa.com]Robbie AkaChopa
 
APBN
APBNAPBN
Hello, I am a Business Analyst
Hello, I am a Business AnalystHello, I am a Business Analyst
Hello, I am a Business Analyst
Jason Prine
 
[Www.akachopa.com]sbmptn 2013 tkdu
[Www.akachopa.com]sbmptn 2013 tkdu[Www.akachopa.com]sbmptn 2013 tkdu
[Www.akachopa.com]sbmptn 2013 tkduRobbie AkaChopa
 
Jadwal pembekalan kkn 73 kelompok iv fak. pertanian, fak. teknik 12 13 juni 2...
Jadwal pembekalan kkn 73 kelompok iv fak. pertanian, fak. teknik 12 13 juni 2...Jadwal pembekalan kkn 73 kelompok iv fak. pertanian, fak. teknik 12 13 juni 2...
Jadwal pembekalan kkn 73 kelompok iv fak. pertanian, fak. teknik 12 13 juni 2...Robbie AkaChopa
 
[Www.akachopa.com]sbmptn 2013 soshum
[Www.akachopa.com]sbmptn 2013 soshum[Www.akachopa.com]sbmptn 2013 soshum
[Www.akachopa.com]sbmptn 2013 soshumRobbie AkaChopa
 
3 class definition
3 class definition3 class definition
3 class definition
Robbie AkaChopa
 

Viewers also liked (18)

5 mis-sustainable development
5 mis-sustainable development5 mis-sustainable development
5 mis-sustainable development
 
White Paper_RIBER_Kunal
White Paper_RIBER_KunalWhite Paper_RIBER_Kunal
White Paper_RIBER_Kunal
 
Un trago muy original
Un trago muy originalUn trago muy original
Un trago muy original
 
Bahan ajar ekonomi kredit
Bahan ajar ekonomi kreditBahan ajar ekonomi kredit
Bahan ajar ekonomi kredit
 
Snmptn 2012 tbs [akachopa.com]
Snmptn 2012 tbs [akachopa.com]Snmptn 2012 tbs [akachopa.com]
Snmptn 2012 tbs [akachopa.com]
 
Snmptn 2012 ipa [akachopa.com]
Snmptn 2012 ipa [akachopa.com]Snmptn 2012 ipa [akachopa.com]
Snmptn 2012 ipa [akachopa.com]
 
APBN
APBNAPBN
APBN
 
Bab i
Bab iBab i
Bab i
 
10 mis-green it
10 mis-green it10 mis-green it
10 mis-green it
 
Hello, I am a Business Analyst
Hello, I am a Business AnalystHello, I am a Business Analyst
Hello, I am a Business Analyst
 
[Www.akachopa.com]sbmptn 2013 tkdu
[Www.akachopa.com]sbmptn 2013 tkdu[Www.akachopa.com]sbmptn 2013 tkdu
[Www.akachopa.com]sbmptn 2013 tkdu
 
Jadwal pembekalan kkn 73 kelompok iv fak. pertanian, fak. teknik 12 13 juni 2...
Jadwal pembekalan kkn 73 kelompok iv fak. pertanian, fak. teknik 12 13 juni 2...Jadwal pembekalan kkn 73 kelompok iv fak. pertanian, fak. teknik 12 13 juni 2...
Jadwal pembekalan kkn 73 kelompok iv fak. pertanian, fak. teknik 12 13 juni 2...
 
10. deadlock
10. deadlock10. deadlock
10. deadlock
 
Tabel distribusi
Tabel distribusiTabel distribusi
Tabel distribusi
 
[Www.akachopa.com]sbmptn 2013 soshum
[Www.akachopa.com]sbmptn 2013 soshum[Www.akachopa.com]sbmptn 2013 soshum
[Www.akachopa.com]sbmptn 2013 soshum
 
3 class definition
3 class definition3 class definition
3 class definition
 
Inferensi statistik
Inferensi statistikInferensi statistik
Inferensi statistik
 
Konsep dasar statistik
Konsep dasar statistikKonsep dasar statistik
Konsep dasar statistik
 

Similar to 2.oop concept

Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
mustafa sarac
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
01. design pattern
01. design pattern01. design pattern
01. design pattern
MD Sayem Ahmed
 
JAVA-PPT'S.pdf
JAVA-PPT'S.pdfJAVA-PPT'S.pdf
JAVA-PPT'S.pdf
AnmolVerma363503
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
ArpitaJana28
 
Java Progamming Paradigms, OOPS Concept, Introduction to Java, Structure of J...
Java Progamming Paradigms, OOPS Concept, Introduction to Java, Structure of J...Java Progamming Paradigms, OOPS Concept, Introduction to Java, Structure of J...
Java Progamming Paradigms, OOPS Concept, Introduction to Java, Structure of J...
Sakthi Durai
 
MCA NOTES.pdf
MCA NOTES.pdfMCA NOTES.pdf
MCA NOTES.pdf
RAJASEKHARV10
 
Review oop and ood
Review oop and oodReview oop and ood
Review oop and ood
than sare
 
POP vs OOP Introduction
POP vs OOP IntroductionPOP vs OOP Introduction
POP vs OOP Introduction
Hashni T
 
Object oriented programming concept
Object oriented programming conceptObject oriented programming concept
Object oriented programming concept
Pina Parmar
 
Python-Classes.pptx
Python-Classes.pptxPython-Classes.pptx
Python-Classes.pptx
Karudaiyar Ganapathy
 
Object oriented software engineering concepts
Object oriented software engineering conceptsObject oriented software engineering concepts
Object oriented software engineering conceptsKomal Singh
 
Oops concepts
Oops conceptsOops concepts
Oops concepts
ACCESS Health Digital
 
M.c.a. (sem iv)- java programming
M.c.a. (sem   iv)- java programmingM.c.a. (sem   iv)- java programming
M.c.a. (sem iv)- java programming
Praveen Chowdary
 

Similar to 2.oop concept (20)

Unit 1 Java
Unit 1 JavaUnit 1 Java
Unit 1 Java
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in Java
 
01. design pattern
01. design pattern01. design pattern
01. design pattern
 
Class 4
Class 4Class 4
Class 4
 
Java chapter 3
Java   chapter 3Java   chapter 3
Java chapter 3
 
JAVA-PPT'S.pdf
JAVA-PPT'S.pdfJAVA-PPT'S.pdf
JAVA-PPT'S.pdf
 
Oops
OopsOops
Oops
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
 
Java Progamming Paradigms, OOPS Concept, Introduction to Java, Structure of J...
Java Progamming Paradigms, OOPS Concept, Introduction to Java, Structure of J...Java Progamming Paradigms, OOPS Concept, Introduction to Java, Structure of J...
Java Progamming Paradigms, OOPS Concept, Introduction to Java, Structure of J...
 
MCA NOTES.pdf
MCA NOTES.pdfMCA NOTES.pdf
MCA NOTES.pdf
 
Review oop and ood
Review oop and oodReview oop and ood
Review oop and ood
 
POP vs OOP Introduction
POP vs OOP IntroductionPOP vs OOP Introduction
POP vs OOP Introduction
 
Object oriented programming concept
Object oriented programming conceptObject oriented programming concept
Object oriented programming concept
 
Oop basic concepts
Oop basic conceptsOop basic concepts
Oop basic concepts
 
Python-Classes.pptx
Python-Classes.pptxPython-Classes.pptx
Python-Classes.pptx
 
Lecture 5.pptx
Lecture 5.pptxLecture 5.pptx
Lecture 5.pptx
 
Object oriented software engineering concepts
Object oriented software engineering conceptsObject oriented software engineering concepts
Object oriented software engineering concepts
 
Oops concepts
Oops conceptsOops concepts
Oops concepts
 
M.c.a. (sem iv)- java programming
M.c.a. (sem   iv)- java programmingM.c.a. (sem   iv)- java programming
M.c.a. (sem iv)- java programming
 

More from Robbie AkaChopa

Monetisasi blog 1
Monetisasi blog 1Monetisasi blog 1
Monetisasi blog 1
Robbie AkaChopa
 
[Www.akachopa.com]sbmptn 2013 tpa
[Www.akachopa.com]sbmptn 2013 tpa[Www.akachopa.com]sbmptn 2013 tpa
[Www.akachopa.com]sbmptn 2013 tpaRobbie AkaChopa
 
[Www.akachopa.com]sbmptn 2013 saintek
[Www.akachopa.com]sbmptn 2013 saintek[Www.akachopa.com]sbmptn 2013 saintek
[Www.akachopa.com]sbmptn 2013 saintekRobbie AkaChopa
 
Snmptn 2012 tpa [akachopa.com]
Snmptn 2012 tpa [akachopa.com]Snmptn 2012 tpa [akachopa.com]
Snmptn 2012 tpa [akachopa.com]Robbie AkaChopa
 
Snmptn 2012 ips [akachopa.com]
Snmptn 2012 ips [akachopa.com]Snmptn 2012 ips [akachopa.com]
Snmptn 2012 ips [akachopa.com]Robbie AkaChopa
 
Inferensi statistik satu populasi
Inferensi statistik satu populasiInferensi statistik satu populasi
Inferensi statistik satu populasiRobbie AkaChopa
 
Tugas tba kelompok 1 kelas b
Tugas tba kelompok 1 kelas bTugas tba kelompok 1 kelas b
Tugas tba kelompok 1 kelas bRobbie AkaChopa
 
[Tep667][t02][06835;06923;07722][final]
[Tep667][t02][06835;06923;07722][final][Tep667][t02][06835;06923;07722][final]
[Tep667][t02][06835;06923;07722][final]Robbie AkaChopa
 
9 mis-collaboration platform
9 mis-collaboration platform9 mis-collaboration platform
9 mis-collaboration platformRobbie AkaChopa
 

More from Robbie AkaChopa (20)

Monetisasi blog 1
Monetisasi blog 1Monetisasi blog 1
Monetisasi blog 1
 
[Www.akachopa.com]sbmptn 2013 tpa
[Www.akachopa.com]sbmptn 2013 tpa[Www.akachopa.com]sbmptn 2013 tpa
[Www.akachopa.com]sbmptn 2013 tpa
 
[Www.akachopa.com]sbmptn 2013 saintek
[Www.akachopa.com]sbmptn 2013 saintek[Www.akachopa.com]sbmptn 2013 saintek
[Www.akachopa.com]sbmptn 2013 saintek
 
Hasil seleksisnmptn2014
Hasil seleksisnmptn2014Hasil seleksisnmptn2014
Hasil seleksisnmptn2014
 
Snmptn 2012 tpa [akachopa.com]
Snmptn 2012 tpa [akachopa.com]Snmptn 2012 tpa [akachopa.com]
Snmptn 2012 tpa [akachopa.com]
 
Snmptn 2012 ips [akachopa.com]
Snmptn 2012 ips [akachopa.com]Snmptn 2012 ips [akachopa.com]
Snmptn 2012 ips [akachopa.com]
 
Soal stat
Soal statSoal stat
Soal stat
 
09 sinkronisasi proses
09 sinkronisasi proses09 sinkronisasi proses
09 sinkronisasi proses
 
Inferensi statistik satu populasi
Inferensi statistik satu populasiInferensi statistik satu populasi
Inferensi statistik satu populasi
 
Chapter08
Chapter08Chapter08
Chapter08
 
Indonesian quran-wb
Indonesian quran-wbIndonesian quran-wb
Indonesian quran-wb
 
Al quran-pdf
Al quran-pdfAl quran-pdf
Al quran-pdf
 
Presentation
PresentationPresentation
Presentation
 
Tugas akhir
Tugas akhirTugas akhir
Tugas akhir
 
Tugas tba kelompok 1 kelas b
Tugas tba kelompok 1 kelas bTugas tba kelompok 1 kelas b
Tugas tba kelompok 1 kelas b
 
[Tep667][t02][06835;06923;07722][final]
[Tep667][t02][06835;06923;07722][final][Tep667][t02][06835;06923;07722][final]
[Tep667][t02][06835;06923;07722][final]
 
12 mis-the cloud
12 mis-the cloud12 mis-the cloud
12 mis-the cloud
 
11 mis-erp
11 mis-erp11 mis-erp
11 mis-erp
 
7 mis-coorporate
7 mis-coorporate7 mis-coorporate
7 mis-coorporate
 
9 mis-collaboration platform
9 mis-collaboration platform9 mis-collaboration platform
9 mis-collaboration platform
 

Recently uploaded

ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 

Recently uploaded (20)

ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 

2.oop concept

  • 2. OOP Concepts : Illustration Sending Flowers to a Friend  Suppose I wish to send flowers to a friend, Sally, who lives in a city many miles away.  ◦What should I do?
  • 3. Agents and Communities  Solution: Find an appropriate agent, namely Flora, and pass to her a message containing my request  It is the responsibility of Flora to satisfy my request  There is some method–some algorithm or some set of operations –used to satisfy my request  This information, i.e., details, is usually hidden from my inspection.
  • 4. The community of agents helping me
  • 5. An observation  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 performs an action, that is used by other members of the community.
  • 6. Messages and Methods  Action is initiated in OOP by the transmission of a message to an agent (an object) responsible for the action.  The message encodes the request for an action and is accompanied by any additional information (arguments) needed to carry out the request.  The receivers the object to whom the message is sent. If the receiver accepts the message, it accepts the responsibility to carry out the indicated action.  In response to a message, the receiver will perform some method to satisfy the request.
  • 7. Classes and Instances  We can use the term Florist to represent the category (or class) of all florists.  I am able to make certain assumptions because I have information about florists in general, and I expect that Flora, being an instance of this category, will fit the general pattern.  All objects are instances of a class  The method invoked by an object in response to a message is determined by the class of the receiver  All objects of a given class use the same method in response to similar messages.
  • 8.
  • 9.
  • 10.  The principle that knowledge of a more general category is also applicable to a more specific category is called inheritance.  The class Floristwill inherit attributes of the class (or category) Shopkeeper.  Classes can be organized into a hierarchical inheritance structure.  A child class(or subclass) will inherit attributes from a parent class higher in the hierarchy. An abstract parent class is a class for which there are no direct instances; it is used only to create subclasses.
  • 11.  That Liz and my florist Flora will respond to my message by different methods is an example of one form of Polymorphism.  ◦That I do not, need not, know exactly what method Flora will use to honor my message is an example of information hiding.
  • 12. Java: Good and Bad  Good:  Platform independent execution  Platform independent binary data (files etc)  Robust  Does not allow operator overloading. Some people regard this as a limitation. Others think operator overloading is not a good idea anyway!  Comes with a huge class library which allow:  File input / output  Graphics  Event trapping / handling  3D modelling  Bad:  Syntax is adopted from C. This means that some control structures are primitive and unstructured  Graphics library still provides problems across different platforms
  • 13. OO Characteristics 1. Everything is an object. 2. A program is a bunch of objects telling each other what to do by sending messages. 3. Each object has its own memory made up of other objects. 4. Every object has a type. 5. All objects of a particular type can receive the same messages
  • 14.  Everything is an object.  Think of an object as a fancy variable; it stores data, but you can “make requests” to that object, asking it to perform operations on itself. In theory, you can take any conceptual component in the problem you’re trying to solve (dogs, buildings, services, etc.) and represent it as an object in your program.
  • 15.  A program is a bunch of objects telling each other what to do by sending messages.  To make a request of an object, you “send a message” to that object. More concretely, you can think of a message as a request to call a method that belongs to a particular object.  Each object has its own memory made up of other objects.  Put another way, you create a new kind of object by making a package containing existing objects. Thus, you can build complexity into a program while hiding it behind the simplicity of objects.
  • 16.  Every object has a type.  Using the parlance, each object is an instance of a class, in which “class” is synonymous with “type.” The most important distinguishing characteristic of a class is: “What messages can you send to it?”  All objects of a particular type can receive the same messages.  This is actually a loaded statement, as you will see later. Because an object of type “circle” is also an object of type “shape,” a circle is guaranteed to accept shape messages. This means you can write code that talks to shapes and automatically handle anything that fits the description of a shape. This substitutability is one of the powerful concepts in OOP.
  • 17. To be OO or not to be OO?  There are two basic paradigms for designing algorithms:  Non Object Oriented:  Focus is on the steps required to perform the task.  The design of the steps lead to the types of data structures that will be required.  Object Oriented:  Focus is on the entities required. i.e. what are the things that need to be represented in the algorithm and:  what functionality will each thing require.  how these things will communicate with each other.  ◦Each entity will be represented as an object.
  • 18.
  • 20. Creating, Compiling, and Running a Java Program  The Java code on the previous slide is entered into a text file using a text editor  The name of the .java file MUST be EXACTLY the same as the name of the class (ie. Welcome1.java)  The .java file is then compiled into byte code:  The command would be: javac Welcome1.java  If the program contained errors then error messages are displayed  Otherwise the byte code is produced  The byte code is stored in a file called Welcome1.class  The program can then be executed using the command: java Welcome1
  • 21. The main() Method  A Java program starts by executing the main() method  The main() method provides the starting point for the program  Within the main() method:  Other methods will be invoked  Objects will be created and  Methods within those objects invoked  Simple
  • 24. Constructors  Classes have a special method called a constructor that is called when a class instance is created.  ◦The class constructor always has the same name as the class and no return type.  ◦If you do not write your own constructor, the compiler adds an empty constructor, which calls the no-arguments constructor of its parent class.  ◦The empty constructor is called the default constructor.  ◦The default constructor initializes all non-initialized fields and variables to zero.
  • 25. Introduction to Methods  A method consists of  A header  A body  The header consists of  The type of the method  The name of the method  The parameters to the method  The body consists of a sequence of Java statements encapsulated by { and }
  • 26. Methods  A method can be called only for an object, and that object must be able to perform that method call.  Call a method:  objectName.methodName(arg1, arg2, arg3);  The act of calling a method is commonly referred to as sending a message to an object  boolean flag() { return true; }  float naturalLogBase() { return 2.718f; }  void nothing() { return; }  void nothing2() {}
  • 32.
  • 34. Object Oriented Technology  Object-oriented design (OOD)  ◦Models real-world objects  ◦Models communication among objects  ◦Encapsulates attributes and operations (behaviors)  Information hiding  Communication through well-defined interfaces  Object-oriented language  ◦Programming in object-oriented languages is called object-oriented programming (OOP)  ◦Java
  • 35. Introduction to Class Diagram A class diagram shows the existence of classes and their relationships in the logical view of a system
  • 36. Control Structures Two basic types of control structures:  Selection: Given one or more possible choices: choose which section (if any) of an algorithm to execute.  Iteration: Repeat a section of an algorithm provided required conditions are met. Also known as looping.  Selection Control:  The If−Then_Else statement. Provides up to two possible alternatives.  The Case statement. Provides any number of possible alternatives.  Repetition Control:  while  do…while  for
  • 39. Conditional Operator (? : )  Java’s only ternary operator (takes three operands) ? : and its three operands form a conditional expression  Entire conditional expression evaluates to the second operand if the first operand is true  Entire conditional expression evaluates to the third operand if the first operand is false
  • 41. switch Multiple Selection Statement  When the expression matches a case, the statements in the case are executed until:  A break statement is encountered or  The end of the switch statement is encountered  The default clause is optional  If the default clause is supplied then it is executed if the switch expression does not match any of the case constants
  • 43. Mistakes are easy with switch
  • 45. break and continue Statement