-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritance_constructor.java
More file actions
39 lines (36 loc) · 976 Bytes
/
inheritance_constructor.java
File metadata and controls
39 lines (36 loc) · 976 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
package com.company;
class Base1{
public Base1() {
System.out.println("I am base class constructor");
}
public Base1(int x)
{
System.out.println("I am base1 class constructor : "+x);
}
}
class Derived1 extends Base1{
public Derived1() {
System.out.println("I am a derived class constructor");
}
public Derived1(int x,int y)
{
super(x);
System.out.println("I am overloaded constructor : "+y);
}
}
class child extends Derived1{
public child() {
System.out.println("i am child class constructor");
}
public child(int x, int y,int z) {
super(x, y);
System.out.println("I am child derived class constructor : "+z);
}
}
public class inheritance_constructor {
public static void main(String[] args) {
// Base1 b1=new Base1();
// Derived1 d1=new Derived1(5,8);
child c1=new child(2,4,3);
}
}