-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpractice_on_oops.java
91 lines (77 loc) · 1.78 KB
/
practice_on_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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package com.company;
// q 1
/*class Employee {
int Salary;
String name;
public int getSalary(){
return Salary;
}
public String getname(){
return name;
}
public void setname(String n){
name = n;
}
}
*//*
public class practice_on_oops {
/* public static void main(String[]args){
sagar.setname("Sagar Ghodke");
System.out.println(sagar.getname());
sagar.Salary=234;
System.out.println(sagar.getSalary());
//Q2
System.out.println("*** Steps while calling ***");
cellphone realme = new cellphone();
realme.ring();
realme.vibrate();
realme.call();
}
class cellphone {
public void ring (){
System.out.println("ringing");
}
public void vibrate(){
System.out.println("vibrating");
}
public void call(){
System.out.println("calling Arpita");
*/
/* //Q3
System.out.println("for square");
Square sq = new Square();
sq.side=3;
System.out.println(sq.perimeter());
System.out.println(sq.area());
}*/
/*
//Q3
class Square {
int side;
public int area(){
// int area = side*side ;
return side*side;
}
public int perimeter(){
//int perimeter = 4*side;
return 4*side;
}
*/
/*public void (String[] args) {
//For rectangle
reatangle sq = new reatangle();
sq.length = 43;
sq.breadth = 45;
}
class reatangle {
int length;
int breadth;
public int area() {
return length * breadth;
}
public int perimeter() {
return 2 * (length + breadth);
}
}
}
*/