This repository contains Java programs demonstrating important Object-Oriented Programming (OOP) concepts:
- super Keyword using Inheritance
- Access Modifiers in Java (public, private, protected, default)
- Encapsulation using Student class
- Abstract Class with Abstract Methods
- Abstract Class without Abstract Methods
Each program is created to help understand core Java OOP principles with simple examples.
This program explains all four access modifiers:
| Modifier | Accessible Within Class | Within Package | Subclass | Outside Package |
|---|---|---|---|---|
| public | ✔ | ✔ | ✔ | ✔ |
| private | ✔ | ✖ | ✖ | ✖ |
| protected | ✔ | ✔ | ✔ | ✖ (only via inheritance) |
| default | ✔ | ✔ | ✖ | ✖ |
Concepts Covered:
- public
- private
- protected
- default
- Package creation
- Access through inheritance and objects
This program demonstrates Encapsulation, where:
- The variables name, age, and roll_no are private
- Public getter and setter methods are used to access and modify them
Concepts Covered:
- Private data members
- Getters & Setters
- Data hiding
- Secure access to variables
This program demonstrates how the super keyword is used to:
- Call parent class constructor
- Call parent class method
- Access parent class variables
Concepts Covered:
- Inheritance
- super()
- Method overriding
This program shows:
- How to create an abstract class
- How to define abstract methods
- How a subclass implements the abstract methods
Concepts Covered:
- Abstract class
- Abstract method
- Method implementation in child class
This program demonstrates that:
- An abstract class can exist without any abstract methods
- It cannot be instantiated
- It can contain normal methods
Concepts Covered:
- Abstract class
- Concrete methods
- Inheritance
Java-OOP-Assessment-2/
├── JavaAssessment-2/
│ └── src/
│ ├── Package1/
│ │ ├── Supper.java
│ │ └── Sub.java
│ ├── Package2/
│ │ ├── InnerSub.java
│ │ └── AccessModifiers.java
│ ├── Encapsulation/
│ │ └── Student.java
│ ├── AbstractWithMethods/
│ │ └── (files for abstract class with abstract methods)
│ └── AbstractWithoutMethods/
│ └── (files for abstract class without abstract methods)
└── README.md1. Clone the repository:
git clone https://github.com/Shilpask123/Java-OOP-Assessment-2.git2. Open the project in IntelliJ IDEA, Eclipse, or any Java IDE.
3. Navigate to the required file:
Java-OOP-Assessment-2/JavaAssessment-2/src/4. Run the program
This task helps build strong understanding of:
- Inheritance
- Access control
- Encapsulation
- Abstraction
- super keyword
- Java class structure