-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritance.java
More file actions
59 lines (52 loc) · 828 Bytes
/
Copy pathinheritance.java
File metadata and controls
59 lines (52 loc) · 828 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
Input -> 1
Output -> Code
Code
Quotient
newcqcq
*/
class A {
public void m1() {
System.out.println("Coding");
}
public void m2() {
System.out.println("Quotient");
}
public String toString() {
return "cq";
}
}
class B extends A {
public void m1() {
System.out.println("Code");
}
public String toString() {
return (super.toString() + super.toString());
}
}
class C extends B
{
public void m1()
{
super.m1();
}
public void m2()
{
super.m1();
super.m2();
}
public String toString()
{
return ("new"+super.toString());
}
}
class Main
{
public static void main(String[] args)
{
C c=new C();
c.m1();
c.m2();
System.out.println(c.toString());
}
}