/* program to show the concept of Aggregation */
package aggregation;
class Aggregation2
{
int roll;
String name;
String branch;
Aggregation2(int roll,String name,String branch)
{
this.roll=roll;
this.name=name;
this.branch=branch;
}
public int getRollNo()
{
return roll;
}
public String getBranch()
{
return branch;
}
public String getName()
{
return name;
}
}
class Child
{
int marks;
int age;
Aggregation2 ag;
Child(int m,int a,Aggregation2 t)
{
marks=m;
age=a;
ag=t;
}
public void show()
{
System.out.println("The roll number of the student is : "+ag.getRollNo());
System.out.println("Name is : "+ag.getName());
System.out.println("Branch is : "+ag.branch);
System.out.println("Student Age is : "+age);
System.out.println("Student marks is : "+marks);
}
}
class MainClass
{
public static void main(String[] args)
{
Aggregation2 a=new Aggregation2(21,"sanjay","cse");
Child c=new Child(78,14,a);
c.show();
}
}
class Aggregation2
{
int roll;
String name;
String branch;
Aggregation2(int roll,String name,String branch)
{
this.roll=roll;
this.name=name;
this.branch=branch;
}
public int getRollNo()
{
return roll;
}
public String getBranch()
{
return branch;
}
public String getName()
{
return name;
}
}
class Child
{
int marks;
int age;
Aggregation2 ag;
Child(int m,int a,Aggregation2 t)
{
marks=m;
age=a;
ag=t;
}
public void show()
{
System.out.println("The roll number of the student is : "+ag.getRollNo());
System.out.println("Name is : "+ag.getName());
System.out.println("Branch is : "+ag.branch);
System.out.println("Student Age is : "+age);
System.out.println("Student marks is : "+marks);
}
}
class MainClass
{
public static void main(String[] args)
{
Aggregation2 a=new Aggregation2(21,"sanjay","cse");
Child c=new Child(78,14,a);
c.show();
}
}
output
No comments:
Post a Comment