-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
34 lines (29 loc) · 939 Bytes
/
Student.java
File metadata and controls
34 lines (29 loc) · 939 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
public class Student {
int studentID;
String name;
char grade;
public Student() {
this.studentID = 0;
this.name = "unknown";
this.grade = 'A';
}
public Student(int studentID, String name, char grade) {
this.studentID = studentID;
this.name = name;
this.grade = grade;
}
public void printDetails() {
System.out.println("Student ID: " + studentID);
System.out.println("Name: " + name);
System.out.println("Grade: " + grade);
}
public static void main(String args[]) {
Student defaultStudent = new Student();
System.out.println("Default Constructor:");
defaultStudent.printDetails();
System.out.println();
Student parameterizedStudent = new Student(101, "JIGYASU", 'E');
System.out.println("Parameterized Constructor:");
parameterizedStudent.printDetails();
}
}