-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathstudent.java
More file actions
40 lines (31 loc) · 915 Bytes
/
student.java
File metadata and controls
40 lines (31 loc) · 915 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
35
36
37
38
39
40
public class student {
private int rollNo;
public String name;
// constructor-> public, no return type,name same as class name
public student(String n, int rn){ // parameterized
rollNo = rn;
name = n;
}
public student(){} // default constructor
public void setRollNo(int rn){
rollNo = rn;
}
public int getRollNO(){
return rollNo;
}
public void display(){
System.out.println(name + " " + rollNo);
}
public void insertRecord(String n, int rn){
name = n;
rollNo = rn;
}
}
// default -> can be accessed within the same package
// private -> only with in the same class
// public -> visible everywhere
// protected -> in Inheritance
// keywords
// final-> dont want to change the value
// this -> this keyword
// static-> static variable ( object counter )