Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Object-Oriented_Programming_OOP_in_Java

Object-Oriented Programming (OOP) in Java is centered around the concept of 'objects' that combine data and behavior. Key OOP principles include encapsulation, inheritance, polymorphism, and abstraction, which facilitate code organization and reuse. An example demonstrates how a 'Dog' class inherits from an 'Animal' class and overrides its method to provide specific behavior.

Uploaded by

someoneishere721
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Object-Oriented_Programming_OOP_in_Java

Object-Oriented Programming (OOP) in Java is centered around the concept of 'objects' that combine data and behavior. Key OOP principles include encapsulation, inheritance, polymorphism, and abstraction, which facilitate code organization and reuse. An example demonstrates how a 'Dog' class inherits from an 'Animal' class and overrides its method to provide specific behavior.

Uploaded by

someoneishere721
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Object-Oriented Programming (OOP) in Java

Object-Oriented Programming (OOP) in Java

OOP is a programming paradigm based on the concept of "objects", which combine data and
behavior. Java was designed with OOP principles in mind and supports encapsulation, inheritance,
polymorphism, and abstraction.

Key Concepts:
- Classes and Objects: Classes define blueprints; objects are instances.
- Encapsulation: Bundling data and methods while restricting direct access.
- Inheritance: Creating new classes from existing ones to promote code reuse.
- Polymorphism: Allowing objects to be treated as instances of their parent class.
- Abstraction: Hiding complex details while exposing essential features.

Example:
--------------------------------
class Animal {
void sound() {
System.out.println("Animal makes a sound");
}
}

class Dog extends Animal {


@Override
void sound() {
System.out.println("Dog barks");
}
}

public class TestOOP {


public static void main(String[] args) {
Animal myDog = new Dog();
myDog.sound();
}
}
--------------------------------

You might also like