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

java poo

The document provides an overview of Object-Oriented Programming (OOP) in Java, highlighting its advantages over procedural programming, such as improved execution speed and code maintainability. It explains the concepts of classes and objects, detailing how classes serve as templates for objects with defined attributes and methods. Additionally, it introduces UML (Unified Modeling Language) for modeling classes and their relationships, emphasizing the importance of class visibility in defining access levels for attributes and operations.

Uploaded by

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

java poo

The document provides an overview of Object-Oriented Programming (OOP) in Java, highlighting its advantages over procedural programming, such as improved execution speed and code maintainability. It explains the concepts of classes and objects, detailing how classes serve as templates for objects with defined attributes and methods. Additionally, it introduces UML (Unified Modeling Language) for modeling classes and their relationships, emphasizing the importance of class visibility in defining access levels for attributes and operations.

Uploaded by

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

SWE 224 : OOP JAVA

I-INTRODUCTION TO OOP

Definition

OOP stands for Object-Oriented Programming.

Procedural programming is about writing procedures or methods that perform


operations on the data, while object-oriented programming is about creating
objects that contain both data and methods.

Object-oriented programming has several advantages over procedural


programming:

 OOP is faster and easier to execute


 OOP provides a clear structure for the programs
 OOP helps to keep the Java code DRY "Don't Repeat Yourself", and
makes the code easier to maintain, modify and debug
 OOP makes it possible to create full reusable applications with less code
and shorter development time

CLASSES AND OBJECTS

Classes and objects are the two main aspects of object-oriented


programming.

CLASS COUNTRY OBJECT CHINA, CAMEROON, JAPAN


So, a class is a template for objects, and an object is an instance of a class.

A class defines the properties (attributes) and behaviors (methods) that


objects of that class will have.

 Attributes: These are the variables that define the properties of the
object. For example, a Car class might have attributes like color, model,
and year.
 Methods: These are the functions that define the behavior of the object.
For example, a Car class might have methods like start(), stop(), and
accelerate().
When the individual objects are created, they inherit all the variables and
methods from the class.

UML (Unified Modeling Language)

In this part we are going to unified how a class can be medelise. So that if
I’m working in a companie and i modelise class and object to create a
software. And if leave the companie. If another software engeneer join
the compagnie he be able to understand what I was modelising.

The UML Class diagram is a graphical notation used to construct and


visualize object oriented systems. A class diagram in the Unified Modeling
Language (UML) is a type of static structure diagram that describes the
structure of a system by showing the system's:
 classes,
 their attributes,
 operations (or methods),
 and the relationships among objects.
Class Name:
 The name of the class appears in the first partition.

Class Attributes:
 Attributes are shown in the second partition.
 The attribute type is shown after the colon.
 Attributes map onto member variables (data members) in code.

Class Operations (Methods):


 Operations are shown in the third partition. They are services the
class provides.
 The return type of a method is shown after the colon at the end of
the method signature.
 The return type of method parameters are shown after the colon
following the parameter name. Operations map onto class methods
in code

Class Visibility
The +, - and # symbols before an attribute and operation name in a class
denote the visibility of the attribute and operation.

 + denotes public attributes or operations


 - denotes private attributes or operations
 # denotes protected attributes or operations

public class Main {

int x = 5;

public static void main(String[] args) {

Main myObj = new Main();

System.out.println(myObj.x);

You might also like