-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOOPS.java
39 lines (35 loc) · 840 Bytes
/
OOPS.java
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
class Pen{
String colour;
String type;//ball or gel pen ho skta h
public void write(){
System.out.println("write something");
}
public void printColor(){
System.out.println(this.colour);
}
}
class Student{
String nm;
int age;
public void printInfo(){
System.out.println(this.nm);
System.out.println(this.age);
}
}
public class OOPS{
public static void main(String args[]){
Pen pen1=new Pen();
pen1.colour="blue";
pen1.type="gel";
pen1.write();
Pen pen2=new Pen();
pen2.colour="black";
pen2.type="ball";
pen1.printColor();
pen2.printColor();
Student s1=new Student();
s1.nm="Rohan";
s1.age=89;
s1.printInfo();
}
}