Topic 1: Review OOP - zhamri/CSC584-Enterprise_Programming GitHub Wiki
Goal
To reinforce studentsโ understanding of fundamental Object-Oriented Programming (OOP) concepts as a foundation for developing enterprise-level applications using Java.
๐ฏ Learning Objectives
Students should be able to:
- Explain core OOP concepts including objects, classes, and packages
- Apply inheritance and polymorphism in Java programs
- Differentiate between access modifiers (public, protected, private)
- Design abstract classes and implement interfaces
๐ Topics to Cover
- Object-Oriented Programming Concepts
- Objects and Classes
- Packages
- Inheritance
- Extending classes
- Reusing fields and methods
- Polymorphism
- Method overriding
- Dynamic binding
- Access Modifiers
- public, protected, private
- Abstract Classes
- Abstract methods
- When to use abstraction
- Interfaces
- Defining contracts
- Implementing interfaces
๐ ๏ธ Hands-on Activity
Activity: Designing a Simple Class Hierarchy
Students are required to:
- Create a base class: Vehicle
- Attributes: brand, speed
- Method:
displayInfo()
- Create subclasses using inheritance:
- Car
- Motorcycle
- Apply Polymorphism:
- Override
displayInfo()in each subclass - Each class should display different information
- Override
- Use Access Modifiers:
- Apply private, protected, and public appropriately
- Create an Interface: Drivable
- Method:
drive() - Implement this interface in Car and Motorcycle
- Method:
- Use Abstract Class (Optional Enhancement):
- Convert Vehicle into an abstract class
- Add abstract method
startEngine()
Expected Output
Students should produce:
- A simple class diagram (Vehicle โ Car, Motorcycle)
- Java classes demonstrating:
- Inheritance
- Polymorphism
- Interface implementation
- Sample output (console):
Car is driving at 120 km/h
Motorcycle is driving at 80 km/h
๐ Suggested Readings
- Oracle Java Documentation โ OOP Concepts https://docs.oracle.com/javase/tutorial/java/concepts/
- Online tutorial: https://www.w3schools.com/java/java_oop.asp