In this program, You will learn how to implement aggregation in java.
Aggregation in Java represents HAS-A relationship.
"Alternative of Inheritance."
class Abc {
int x = 10;
}
class Main {
Abc obj;
void display() {
obj = new Abc();
System.out.println("The x value is:" + obj.x);
}
public static void main(String args[]) {
Main t = new Main();
t.display();
}
}
Enter 5 Subjects Marks :2 3 4 5 6
The Sum is :20.000000
The Average is :4.000000The x value is:10