Download presentation
Presentation is loading. Please wait.
Published byArline Gregory Modified over 9 years ago
1
Object Oriented Programming Teguh Sutanto Si | STIKOM Surabaya teguh@stikom.edu|+628563076813|http://teguhsutanto.blogspot.com|http://blog.stikom.edu/teguh
2
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
4
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
5
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
6
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.
7
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
8
Concept of Class and Object
9
Classes reflect concepts, objects reflect instances that embody those concepts Daria Jane Brittany Jodie girl class object
12
Class:A class can have three kinds of members: Fields/attribute/data: data variables which determine the status of the class or an object methods: xecutable code of the class built from statements. It allows us to manipulate/change the status of an object or access the value of the data member nested classes and nested interfaces
13
Attribute/Field/Data Method
14
Field Declaration a type name followed by the field name, and optionally an initialization clause primitive data type vs. Object reference – boolean, char, byte, short, int, long, float, double field declarations can be preceded by different modifiers – access control modifiers – static – final
15
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
16
com app Person - name: String - address: String # age: int +getName(): String Employee HRD X MainMenu X
17
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; } public class CreatePencil { public static void main (String args[]){ Pencil p1 = new Pencil(); p1.price = 0.5f; } Pencil.java CreatePencil.java %> javac Pencil.java %> javac CreatePencil.java CreatePencil.java:4: price has private access in Pencil p1.price = 0.5f; ^
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.