-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOOPS.java
More file actions
46 lines (43 loc) · 996 Bytes
/
OOPS.java
File metadata and controls
46 lines (43 loc) · 996 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
46
public class OOPS {
public static void main(String[] args) {
Pen p1 = new Pen(); // created a pen object called p1
p1.setColor("Red");
System.out.println(p1.getColor());
p1.setTip(6);
System.out.println(p1.getTip());
Student s1 = new Student();
/* BankAccount myAcc = new BankAccount();
myAcc.username = "Ankan sen";
myAcc.setPassword("Abc");*/
}
}
/*class BankAccount{
public String username;
private String password;
public void setPassword(String pwd){
password = pwd;
}
}*/
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 Tip){
this.tip = Tip;
}
}
class Student{
String name;
int age;
Student(String name) {
this.name = name;
}
}