-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
40 lines (40 loc) · 1.05 KB
/
Student.java
File metadata and controls
40 lines (40 loc) · 1.05 KB
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
38
39
40
public class Student {
int id;
static int numStudents = 0;
String name;
int marks;
public Student(String s, int i, int m){
this.marks = m;
this.id = i;
this.name = s;
numStudents++;
}
public Student(String s, int i){
this.name = s;
this.id = i;
numStudents++;
}
public Student(String s){
this.name = s;
numStudents++;
}
public Student(){
numStudents++;
}
public void show(){
System.out.println("ID: " + this.id);
System.out.println("Name: " + this.name);
System.out.println("Marks: " + this.marks);
System.out.println("Strength: " + numStudents);
}
public static void main(String[] args){
Student student1 = new Student();
Student student2 = new Student("Deepak");
Student student3 = new Student("Rahul", 1234);
Student student4 = new Student("Ankit", 1234, 90);
student1.show();
student2.show();
student3.show();
student4.show();
}
}