-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccessModifier.java
More file actions
30 lines (25 loc) · 858 Bytes
/
accessModifier.java
File metadata and controls
30 lines (25 loc) · 858 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
package OOPS_By_Apna_College;
class Account {
public String name;
protected String eMail;
private String password;
// getters & setters for using a private
public String getPassword() {
return this.password;
}
public void setPassword(String pass) {
this.password = pass;
}
}
public class accessModifier {
public static void main(String[] args) {
Account account1 = new Account();
account1.name = "Sayan Banik";
account1.eMail = "sayanbanikcob@gmail.com";
// Uncommenting the line below will result in a compilation error
// because password is private
// account1.password = "Sa32432/-@#354";
account1.setPassword("F1M<il6!']I0q>$");
System.out.println("Your Password is: "+account1.getPassword());
}
}