-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAggregationDemo2.java
More file actions
37 lines (37 loc) · 863 Bytes
/
AggregationDemo2.java
File metadata and controls
37 lines (37 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class Address{
int hNo;
String street;
int pincode;
String city;
public Address(int hNo,String street,int pincode,String city){
this.hNo = hNo;
this.street = street;
this.pincode = pincode;
this.city = city;
}
@Override
public String toString(){
return "Address{\n house no : "+hNo+",\n street : "+street+",\n pincode : "+pincode+",\n city : "+city+"}";
}
}
class Student{
int rn;
String name;
Address addr;
public Student(int rn,String name,Address addr){
this.rn = rn;
this.name = name;
this.addr = addr;
}
@Override
public String toString(){
return "Student{\n roll no :"+rn+",\n name : "+name+",\n address : "+addr+"}";
}
}
class AggregationDemo2{
public static void main(String[] args){
Address addr = new Address(108,"A- Block",110033,"Delhi");
Student s = new Student(1,"Tanishq",addr);
System.out.println(s);
}
}