Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 19

God did not give us a spirit of timidity, but a

spirit of power love and of self-discipline.


2 Timothy 1:27
OBJECT ORIENTED CONCEPT
AND TERMINOLOGIES
Object

Class

OBJECT Abstraction

ORIENTED Encapsulation
CONCEPTS
Inheritance

Polymorphism
Object Oriented programming is a programming style which is associated with the concepts like
class, object, Inheritance, Encapsulation, Abstraction, Polymorphism. It focuses on implementing real
world objects using Classes to create variation of object, that has attribute and purpose
OBJECT

Object means a real-world entity such as human, animals, pen, chair, table, etc.
-Properties
-Task performed
-Instance of a class

Example: Person

Name Walk
Age Read
Address Write
Sex Run
CLASS - is a definition of objects of the same kind. In other words, a class is a blueprint, template, or
prototype that defines and describes the static attributes and dynamic behaviors common to all objects
of the same kind.
A Class is a 3-
Compartment Box
Encapsulating Data
and Operations

•A class can be visualized as a three-


compartment box, as illustrated:
•Name (or identity): identifies the
class.
•Variables (or attribute, state, field):
contains the static attributes of the
class.
•Methods (or behaviors, function,
operation): contains the dynamic
behaviors of the class.
CLASS Creation
SYNTAX:

Modifiers className class {

//Attribute
//methods or purpose

}
 
Program:
Example:
Public Person class {
Person //ATTRIBUTES
- FirstName
- Last Name
String firstName;
- Sex
String lastName;
- Age
Char sex;
Int age;
}

SHOW DEMO
Class Instantiation – the process of creating an object using a class
so we can use it on our program

Syntax:
ClassName identifiers = new ClassName();

Example:
Person p = new Person();

SHOW DEMO
ACCESSING Attributes

Syntax:
Sample Program

ClassName identifier = new ClassName(); Person p = new Person();

WRITING Attributes
identifier.attribute = value; p.firstName = “Juan”;
p.lastName = “Cruz”;
p.Sex = ‘M’;
p.Age = 19’
READING Attributes
System.out.println(identifier.attribute);
System.out.println(p.firstName);
CONSTRUCTOR

CREATING Constructor

OOP: Part II THIS keyword

USING CONSTRUCTOR

USER INPUT object creation


Constructors – is a method called when you instantiate a class/create an
object.

- it is used to utilized the attributes of an object or run a block of code


when an object is created.
Creating Constructors
Constructor method are named after their Class Name

SYNTAX: EXAMPLE:

Modifiers className class { public Product class {

className(){ Product(){
//constructor System.out.println(“Product created”);
} }
} }
Creating Constructor
Constructors are used to initialize attributes

EXAMPLE:

public Product class {

String name;
float price;

Product(String name, float price){


this.name = name;
this.price = price
}
}

SHOW DEMO
The this keyword refers to the
class itself.

THIS keyword
The this keyword will enable
you to access global variables
inside the class if you have the
same variable names in a
parameter.
•ClassName identifiers = New
ClassName(parameters);

•Product p1 = new Product(“Milk”, 150.0f);

Using •Product p2 = new Product(“Noodles”, 6.50f);


•Product p3 = new Product(“Bread”, 65.50f);

Constructors
USER INPUT Object Creation

Create a class of your choice then create an object from that


class using user input.
End of Presentation
Thank you and God bless
everyone

You might also like