Java Chapter 1
Java Chapter 1
Programming (Java)
Maiwand University
Faculty of Computer Science
Chapter 1
• What is Programming
• History of Programming
• Programming Approaches
• Object Oriented Programming
• Importance of OOP
• Class and Object
• Properties and Methods in Objects
• Object Relationships in OOP
• Core Principles of OOP
• Encapsulation
• Inheritance
• Polymorphism
What is Programming
• OOP uses real-world objects and their relationships to build models. The
approach mimics human thinking and specialization, making it highly
productive.
• Example:
Class: Car (defines engine, wheels, accelerate, brake)
Object: A specific car with plate number “26 AA 001”
Objects are created based on the class and share the class-defined
behaviors.
Properties and Methods in Objects
• Objects have properties (data like speed, color) and methods (actions like
drive, stop).
• Methods change the state of an object by updating its properties.
• Methods make the object act like a real-life item, enabling interaction and
behavior changes.
Object Relationships in OOP
• Objects can relate to each other through different relationships:
• Association (has-a): One object contains or uses another.
e.g., A Pencil Case has Pencil objects.
• Dependency (uses-a): e.g., A Car depends on Wheels to function.
• One object needs another to work.