-
Notifications
You must be signed in to change notification settings - Fork 0
/
Student.java
32 lines (28 loc) · 931 Bytes
/
Student.java
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
public class Student {
String name;
int roll_no;
String phone_number;
String address;
@Override
public String toString() {
return "Student " +
"name='" + name + '\'' +
", roll_no=" + roll_no +
", phone_number='" + phone_number + '\'' +
", address='" + address + '\'' +
" of Exercise 2";
}
Student(String name, int roll_no, String phone, String address) {
this.name = name;
this.roll_no = roll_no;
this.phone_number = phone;
this.address = address;
}
public static void main(String[] args) {
// Exercise 2
Student student1 = new Student("John", 2, "6634567820", "Delhi");
Student student2 = new Student("Sam", 3, "12345678923", "Noida");
System.out.println(student1.toString());
System.out.println(student2.toString());
}
}