Objected oriented programming(OOP)
In procedural programming languages(like C), programming like to be action-oriented, whereas in JAVA - programming is Object-oriented.
In OOP, programmer like to defined their own self-defined types, called classes.
Each class will contain the data and the set of the method that manipulate the data.
A user defined type(eg.class) is called a object.
Inheritance
Inheritance relations form tree-like hierarchical structure.
(eg. postgraduate students is a subclass of students)
In a “Is a” relationship, an object of a subclass may also be treated as an object
of superclass.
In a “Has a” relationship, a class object has an object of another class to store its
state or do its work. It “has-a” reference to that other object.
Designing a Class
- Always try to keep data private
- Creating an object may require different actions such as initialization
- Break up class with many responsibilities