Skip to content

Commit 6aa3d7f

Browse files
committed
Section 12 Inheritance
Signed-off-by: https://github.com/Someshdiwan <[email protected]>
1 parent 8dc5fe1 commit 6aa3d7f

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed
Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,46 @@
1-
//Need Practice the same thing again.
2-
//Solve Again Revise This.
3-
41
class RectangleSuper{
52
int length;
63
int breadth;
74

85
// Default constructor
9-
RectangleSuper()
10-
{
6+
RectangleSuper() {
117
length=breadth=1;
128
}
139

1410
// Parameterized constructor
15-
RectangleSuper(int l, int b)
16-
{
11+
RectangleSuper(int l, int b) {
1712
length=l;
1813
breadth=b;
1914
}
2015
}
2116

22-
class CuboidSuper extends RectangleSuper
23-
{
17+
class CuboidSuper extends RectangleSuper {
2418
int height;
2519

2620
// Default constructor with super()
27-
CuboidSuper()
28-
{
21+
CuboidSuper() {
2922
super(); // Calls the default constructor of RectangleSuper
3023
height=1;
3124
}
3225

33-
CuboidSuper(int h)
34-
{
26+
CuboidSuper(int h) {
3527
super();
3628
height=h;
3729
}
3830

39-
CuboidSuper(int l, int b,int h)
40-
{
31+
CuboidSuper(int l, int b,int h) {
4132
super(l,b);
4233
height=h;
4334
}
4435

45-
int volume()
46-
{
36+
int volume() {
4737
return length*breadth*height;
4838
}
4939
}
5040

51-
public class ThisVSSuperIMP
52-
{
53-
public static void main(String[] args)
54-
{
41+
public class ThisVSSuperIMP {
42+
public static void main(String[] args) {
5543
CuboidSuper c= new CuboidSuper(5,3,7);
5644
System.out.println("Volumne of Cuboid: "+c.volume());
5745
}
58-
}
46+
}

0 commit comments

Comments
 (0)