-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQB 796.java
More file actions
41 lines (32 loc) · 779 Bytes
/
QB 796.java
File metadata and controls
41 lines (32 loc) · 779 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
//QB 796
class rectangle {
int length;
int breadth;
void area() {
System.out.println("Area of rectangle is " + length * breadth);
}
void perimeter() {
System.out.println("Perimeter of rectangle is " + 2 * (length + breadth));
}
rectangle(int x, int y) {
length = x;
breadth = y;
}
}
class square extends rectangle {
int temp;
square(int side) {
super(side, side);
temp = side;
}
void sq() {
System.out.println("Area of square is: " + temp * temp);
System.out.println("Perimeter of square is: " + 4 * temp);
}
public static void main(String[] args) {
square s = new square(10);
s.sq();
s.area();
s.perimeter();
}
}