-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram#E.java
More file actions
43 lines (40 loc) · 1.04 KB
/
Program#E.java
File metadata and controls
43 lines (40 loc) · 1.04 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
41
42
43
/* Create a class Student with private attributes like rollNumber, name, and grade. Use getter and setter methods to access and modify these attributes.
Name:Shibin M S
Name:111
Name:A+
*/
class Main {
public static void main(String [] args)
{
Student s1=new Student();
s1.setrollNumber(111);
s1.setName("Shibin M S");
s1.setGrade("A+");
System.out.println("Name:"+s1.getName());
System.out.println("Name:"+s1.getrollNumber());
System.out.println("Name:"+s1.getGrade());
}
}
class Student {
private int rollNumber;
private String name;
private String grade;
public int getrollNumber(){
return rollNumber;
}
public String getName(){
return name;
}
public String getGrade(){
return grade;
}
public void setrollNumber(int rollNumber){
this.rollNumber=rollNumber;
}
public void setName(String name){
this.name=name;
}
public void setGrade(String grade){
this.grade=grade;
}
}