0% found this document useful (0 votes)
18 views15 pages

OOP 1 Lesson 1

This document introduces Object-Oriented Programming (OOP) concepts such as encapsulation, classes, and objects, emphasizing their importance in Java programming. It explains the characteristics of objects, including state, behavior, and identity, and outlines the benefits of OOP, such as modularity and code reusability. The document also includes an activity for creating a simple Java program.

Uploaded by

Rainanz Socuano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views15 pages

OOP 1 Lesson 1

This document introduces Object-Oriented Programming (OOP) concepts such as encapsulation, classes, and objects, emphasizing their importance in Java programming. It explains the characteristics of objects, including state, behavior, and identity, and outlines the benefits of OOP, such as modularity and code reusability. The document also includes an activity for creating a simple Java program.

Uploaded by

Rainanz Socuano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

OBJECT - ORIENTED PROGRAMMING 1

LESSON 1

Topic 1: Object - Oriented programming


Concepts
Encapsulation ,objects , class

Topic 2. Inheritance, Polymorphism, and


package
Topic 1: Object - Oriented programming Concepts
Encapsulation ,objects , class

SPECIFIC LEARNING OUTCOMES:

EXPLAIN THE BASIC CONCEPTS OF PROGRAMMING USING


DIFFERENT PROGRAMMING LANGUAGE IMPLEMENTING
ENCAPSULATION, CLASS, AND OBJECTS.

INTERNALIZE THE IMPORTANCE OF JAVA PROGRAMMING


USING OBJECT ORIENTED PROGRAMMING APPROACH.

MANIPULATE THE DIFFERENT JAVA TRAITS THAT APPLY


OBJECT ORIENTED PROGRAMMING CONCEPTS.
WHAT IS OBJECT ORIENTED
PROGRAMMING?

 Object - Oriented programming (OOP)


is a programming paradigm that relies
on the concept of classes and objects.

 It
is used to structure a software
program into simple, reusable pieces of
code blueprints (usually called classes),
which are used to create individual
instances of objects.
What is
Encapsulation?
ENCAPSULATION IS ONE OF THE
FUNDAMENTAL CONCEPTS IN OBJECT-ORIENTED
PROGRAMMING (OOP).

IT DESCRIBES THE IDEA OF BUNDLING DATA


AND METHODS THAT WORK ON THAT DATA WITHIN
ONE UNIT, E.G., A CLASS IN JAVA. THIS CONCEPT
IS ALSO OFTEN USED TO HIDE THE INTERNAL
REPRESENTATION, OR STATE, OF AN OBJECT FROM
THE OUTSIDE. THIS IS CALLED INFORMATION
HIDING.
WHAT IS A CLASS?

A class is a blueprint or prototype from


which objects are created. This section
defines a class that models the state and
behavior of a real-world object. It
intentionally focuses on the basics, showing
how even a simple class can cleanly model
state and behavior.

A class is the blueprint from which


individual objects are created.
 Class

Name student

Name
Variables Id num
address
methods Read()
Write()
Play()
class student{
int id_num;
String address;

void read(){
to do code here;
}
void write(){
to do code here;

}
}
 Classes can also contain functions,
called methods available only to objects of that
type. These functions are defined within the class
and perform some action helpful to that specific
type of object.
 For example, our Car class may have a
method repaint that changes the color attribute
of our car. This function is only helpful to objects
of type Car, so we declare it within the Car class
thus making it a method.
WHAT IS AN OBJECT?

 An object is a software bundle of related


state and behavior. Software objects are
often used to model the real-world objects
that you find in everyday life. This lesson
explains how state and behavior are
represented within an object, introduces
the concept of data encapsulation, and
explains the benefits of designing your
software in this manner.
CHARACTERISTICS OF OBJECTS
 State: what the objects have, Student have
a first name, last name, age, etc.
 Behavior: what the objects do, Student
attend a course "Java for beginners"
 Identity: what makes them unique,
Student have Student-ID-number, or an
email which is unique. (this is important
when implementing the equals method, to
determine if the objects are different or
not)
State - Instance Variable, the variable you use in the
class.
Ex:
public String pageName;
private int pageNumber;

//instance variable with a private access


}

Behavior - Method/function, the method/function you use


in the class.

Ex: void applyBrakes(int decrement) {


speed = speed - decrement;
}
 A method must be declared within a class. It is
defined with the name of the method, followed by
parentheses ().
Example
 Create a method inside MyClass:

 public class MySampleClass {

static void mySampleMethod() {

 }
Consider a bicycle, for example:

A bicycle modelled as a software object.


BUNDLING CODE INTO INDIVIDUAL SOFTWARE
OBJECTS PROVIDES A NUMBER OF BENEFITS,
INCLUDING:

 Modularity: The source code for an object can be written and


maintained independently of the source code for other objects.
Once created, an object can be easily passed around inside the
system.
 Information-hiding: By interacting only with an object's
methods, the details of its internal implementation remain
hidden from the outside world.
 Code re-use: If an object already exists (perhaps written by
another software developer), you can use that object in your
program. This allows specialists to implement/test/debug
complex, task-specific objects, which you can then trust to run
in your own code.
 Plug ability and debugging ease: If a particular object
turns out to be problematic, you can simply remove it from
your application and plug in a different object as its
replacement. This is analogous to fixing mechanical
ACTIVITY # 1
 Demonstrate the process of creating a program in
Java saving file, linking , compiling and running
to display message “ This is a sample Java
Program”.

 20 points
THANK YOU..

You might also like