-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.java
More file actions
42 lines (39 loc) · 735 Bytes
/
Copy pathMain.java
File metadata and controls
42 lines (39 loc) · 735 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
42
package stack;
/*class Superclass
{ Superclass()
{
System.out.println("Printed in Superclass.");
}
}
class Subclass extends Superclass
{ // overrides printMethod in Superclass
Subclass()
{ super();
System.out.println("Printed in Subclass");
}
public static void main(String[] args)
{ Subclass s = new Subclass();
}}
*/
class Base {
int x;
Base(int _x) {
x = _x;
}
}
class Derived extends Base {
int y;
Derived(int _x, int _y) {
super(_x);
y = _y;
}
void Display() {
System.out.println("x = "+x+", y = "+y);
}
}
public class Main {
public static void main(String[] args) {
Derived d = new Derived(10, 20);
d.Display();
}
}