Object oriented programming is a programming paradigm that uses objects and their interactions to design applications and computer programs. Key concepts of OOP include encapsulation, inheritance, polymorphism, and abstraction. Objects contain data in fields and code in methods that operate on their data which allows objects to receive and respond to messages to perform actions.
8. Encapsulation)
private
public get/set
data class Full Encapsulation
class
9. Inheritance)
Class
Class
Class
- Class
Subclasses
- Class Superclass
Reusable)
Class Superclass Class
Single Inheritance)
extends
10. - Overridden method
- Dynamic Binding
OOP
Object class main
>> object
x
>> class
object
class x {
public static void main(String args[]) {
System.out.println("x");
11. object class class
object
>> object object 1
object 2
class x {
public static void main(String args[]) {
int i = 1;
System.out.println(i);
ok(); }
static void ok() {
System.out.println("xx");
}
}
// Result of this program
// 1
// xx