0% found this document useful (0 votes)
106 views

Object Oriented Programming

Object-oriented programming (OOP) is a programming paradigm that uses objects and their interactions to design applications and programs. OOP uses classes which define data structures consisting of data fields and methods, and objects which are instances of classes. The document discusses the concepts of classes and objects, class members like attributes, methods and access modifiers, and provides examples of how classes and objects are defined and used in Java code.

Uploaded by

teguhs
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views

Object Oriented Programming

Object-oriented programming (OOP) is a programming paradigm that uses objects and their interactions to design applications and programs. OOP uses classes which define data structures consisting of data fields and methods, and objects which are instances of classes. The document discusses the concepts of classes and objects, class members like attributes, methods and access modifiers, and provides examples of how classes and objects are defined and used in Java code.

Uploaded by

teguhs
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 18

Object Oriented Programming

TeguhSutanto
Si | STIKOM Surabaya
teguh@stikom.edu|+628563076813|http://teguhsutanto.blogspot.com|http://blog.stikom.edu/teguh

GOAL
1.Students can understand the Object Oriented Programming concepts 2.Students can make a program in accordance with the rules of Object Oriented Programming

Object-oriented programming (OOP) is a programming paradigm using "objects" data structures consisting of data fields and methods together with their interactions to design applications and computer programs

Object-oriented programming (OOP) is a programming language model organized around "objects" rather than "actions" and data rather than logic. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data

Why OOP?
1. Object-oriented systems can be easily upgraded from small to large scale. 2. It is easy to partition the work in a project based on objects. 3. Object-oriented programming offers a new and powerful model for writing computer software. 4. It reduces software maintenance and developing costs. 5. Changes in user requirements or later developments have always been a major problem. 6. Object-orientation or object oriented programming (OOP) should help one in developing high quality software easily.

Concept of Class and Object


Class refers to a blueprint. It defines the variables and methods the objects support Object is an instance of a class. Each object has a class which defines its data and behavior

Concept of Class and Object

Classes reflect concepts, objects reflect instances that embody those concepts
object class
girl

Jodie

Daria

Jane

Brittany

Class:A class can have three kinds of members:

Attribute/Field/Data

Method

Field Declaration
a type name followed by the field name, and optionally an initialization clause primitive data type vs. Object reference
o

boolean, char, byte, short, int, long, float, double

field declarations can be preceded by different modifiers


o o o

access control modifiers static final

Acces Control Modifier


1.private: private members are accessible only in the class itself 2.package: package members are accessible in classes in the same package and the class itself 3.protected: protected members are accessible in classes in the same package, in subclasses of the class, and in the class itself 4.public: public members are accessible anywhere the class is accessible

com
Person
name: String address: String # age: int +getName(): String
X

MainMenu
X

Employee

HRD

Pencil.java

public class Pencil { public String color = red; public int length; public float diameter; private float price; public static long nextID = 0; public void setPrice (float newPrice) { price = newPrice; } }

CreatePencil.java public class CreatePencil {

public static void main (String args[]){ Pencil p1 = new Pencil(); p1.price = 0.5f; }

}
%> javac Pencil.java %> javac CreatePencil.java CreatePencil.java:4: price has private access in Pencil p1.price = 0.5f; ^

You might also like