OOP ( Oriented Object Programming ) in JAVA
OOP ( Oriented Object Programming ) in JAVA
Dr Benabderrezak
Researcher in Cyber Security
Full-stack Web developer 1
OOP?
2
OOP ?
3
Class
4
Class
5
How to declare Class in Java
6
How to use Class in Java ⇒ Create First Object
7
OOP Examples
8
First Program using JAVA + OOP
9
10
Program 2
11
Program 3
12
Program 4
13
Program 4
14
Getters & Setters
15
Getter
- A method used to retrieve the value of a private attribute
16
Setter
- A method used to set or update the value of a private attribute
17
18
Method overloading
19
Method overloading
When a class have multiple methods by same name but different parameters
20
Method overloading
21
Method overriding
22
Method overriding
When a subclass provides a specific implementation for a method in its parent
class.
23
Method overriding
24
Constructor
25
What is a Constructor in Java ?
26
27
28
29
OOP Concepts
30
OOP Concepts
1. Polymorphism
2. Inheritance
3. Encapsulation
4. Abstraction
31
Polymorphism : means many forms (same method but different use in each
subclass )
32
Inheritance :
Allowing classes to inherit common properties & methods from the parent class
33
Inheritance :
34
Inheritance :
35
Encapsulation
It refers to the bundling of data with the methods in a class
36
Abstraction
37
Abstraction
it is achieved through :
● Abstract classes
● Interfaces
38
Abstraction
Abstract classes
39
Abstraction - Abstract classes
40
Abstraction - Abstract classes
41
Abstraction - Abstract classes
42
43
Abstraction
Interfaces
44
Abstraction - Interfaces
- It only defines the methods, but it doesn’t say how they work
- The classes that implement the interface must provide the specific behavior
(method implementation)
45
Abstraction - Interfaces
46
Abstraction - Interfaces
47
Abstraction - Interfaces
48
Practical Scenario
49
Scenario: Library Management System
- The library has books with titles, authors, and availability status
50
Scenario: Library Management System
1. Book : Represents a book with details like title, author, and availability
51
2. Book class :
52
2. Book class :
53
2. Book class :
54
3. Member Class :
55
4. Transaction Class
56
4. Transaction Class
57
5. Library Class
58
5. Library Class
59
5. Library Class
60
5. Library Class
61
6. Use the System in Main Program
62
6. Use the System in Main Program
63
6. Use the System in Main Program
64
6. Use the System in Main Program
65
66