Core Java Interview
Core Java Interview
5) What is aggregation?
Aggregation can be defined as the relationship between two classes where the
aggregate class contains a reference to the class it owns. Aggregation is best described
as a has-a relationship. For example, The aggregate class Employee having various
fields such as age, name, and salary also contains an object of Address class having
various fields such as Address-Line 1, City, State, and pin-code. In other words, we can
say that Employee (class) has an object of Address class. Consider the following
example.
6) What is super in java?
The super keyword in Java is a reference variable that is used to refer to the immediate
parent class object. Whenever you create the instance of the subclass, an instance of
the parent class is created implicitly which is referred by super reference variable. The
super() is called in the class constructor implicitly by the compiler if there is no super
or this.