-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathStudent.java
90 lines (61 loc) · 1.73 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
class StudentInfo{
private static int total;
private int rollnum;
private float marks;
String name;
char grade;
//boolean bool;
static{
System.out.println("This will run in the begening "+total);
}
static int checkTotal(){
return total;
}
StudentInfo(String name, int rollnum){ //parameteerised Constructor
total++;
this.rollnum = rollnum;
this.name = name;
//marks = 20.0f;
grade = 'X';
}
void setData(String name, int rollnum, float marks){
this.rollnum=rollnum;
this.marks=marks;
this.name = name;
}
void getData(){
System.out.println("Name: "+name);
System.out.println("Roll: "+rollnum);
System.out.println("Marks: "+marks);
System.out.println("Grade: "+grade);
//System.out.println("Boolean : "+bool);
}
char calGrade(){
grade = (marks>50.0f)?'P':'F';
return grade;
}
}
class Student{
public static void main(String[] args) {
System.out.println("Total Student "+ StudentInfo.checkTotal());
StudentInfo s1 = new StudentInfo("Sai", 45); // declare reference to object
s1.getData();
System.out.println("Total Student "+ s1.checkTotal());
//StudentInfo.total =50;
StudentInfo s2 = new StudentInfo("Alwyn", 15);
s2.getData();
System.out.println("Total Student "+ s1.checkTotal());
//int test;
//s1.setData("Rupesh", 45,56.78f);
//char grade = s1.calGrade();
//StudentInfo copys1 = s1;
//copys1.name = "Vishwa";
//System.out.println("Details of Student s1");
// allocate a StudentInfo object
//System.out.println("Details of Student copy of s1");
//copys1.getData();
//System.out.println("int: "+test);
//s1.marks = 35.6f;
//System.out.println("My New Roll No: "+si.rollnum+si.marks);
}
}