-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectOrinted.java
More file actions
45 lines (40 loc) · 940 Bytes
/
Copy pathObjectOrinted.java
File metadata and controls
45 lines (40 loc) · 940 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
41
42
43
44
45
public class ObjectOrinted {
public static void main(String[] args) {
pen p = new pen();
p.setcolor("Blue");
System.out.println(p.getcolor());
p.setTip(10);
System.out.println(p.getTip());
// BankAcc myAcc = new BankAcc();
// myAcc.username = "Mayank Rai";
// // myAcc.password = "Varunk@12"; cant access because password is private class
// myAcc.setPassword("Varunk@12");
}
}
class BankAcc{
public String username;
private String password;
public void setPassword(String pass)
{
password = pass;
}
}
class pen{
private String color;
private int tip;
String getcolor(){
return this.color;
}
int getTip()
{
return this.tip;
}
void setcolor(String newcolor)
{
this.color = newcolor;
}
void setTip (int newtip)
{
this.tip = newtip;
}
}