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

EObject-Oriented Programming OOP in Java

Object-Oriented Programming (OOP) in Java is based on the concept of 'objects' that combine data and behavior, supporting principles like encapsulation, inheritance, polymorphism, and abstraction. Key concepts include classes and objects, encapsulation, inheritance, polymorphism, and abstraction. An example demonstrates inheritance where a Dog class extends an Animal class and overrides its sound method.

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)
5 views

EObject-Oriented Programming OOP in Java

Object-Oriented Programming (OOP) in Java is based on the concept of 'objects' that combine data and behavior, supporting principles like encapsulation, inheritance, polymorphism, and abstraction. Key concepts include classes and objects, encapsulation, inheritance, polymorphism, and abstraction. An example demonstrates inheritance where a Dog class extends an Animal class and overrides its sound method.

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