File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ public class Student {
2
+ private int age ;
3
+ private String name ;
4
+
5
+ // Default constructor
6
+ public Student () {
7
+ this .age = 0 ;
8
+ this .name = "" ;
9
+ }
10
+
11
+ // Parameterized constructor
12
+ public Student (int age , String name ) {
13
+ this .age = age ;
14
+ this .name = name ;
15
+ }
16
+
17
+ // Getter for age
18
+ public int getAge () {
19
+ return age ;
20
+ }
21
+
22
+ // Setter for age
23
+ public void setAge (int age ) {
24
+ this .age = age ;
25
+ }
26
+
27
+ // Getter for name
28
+ public String getName () {
29
+ return name ;
30
+ }
31
+
32
+ // Setter for name
33
+ public void setName (String name ) {
34
+ this .name = name ;
35
+ }
36
+
37
+ // For easy display
38
+ @ Override
39
+ public String toString () {
40
+ return "Student{name='" + name + "', age=" + age + "}" ;
41
+ }
42
+ }
You can’t perform that action at this time.
0 commit comments