-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChildi.java
More file actions
50 lines (37 loc) · 947 Bytes
/
Childi.java
File metadata and controls
50 lines (37 loc) · 947 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
package com.interview.all;
class Parenti {
int x = 10;
public void show() {
System.out.println("Inside parent show method");
}
public void show1() {
System.out.println("Inside parent show1 method");
}
}
public class Childi extends Parenti {
int x = 20;
@Override
public void show() {
System.out.println("Inside child show method");
}
public void display() {
System.out.println("Inside child display method");
}
void print(double i, int j) {
System.out.println("This is meth1");
}
void print(int i, double j) {
System.out.println("This is meth2");
}
public static void main(String[] args) {
Parenti parenti = new Childi();
// Child child = new Parent(); // child can not give reference to parent
parenti.show();
parenti.show1();
// parent.display();
System.out.println(parenti.x);
Childi child = new Childi();
child.print(10.0, 10); // it will give ambiguous
child.print(10, 10.0);
}
}