-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinalkey.java
More file actions
54 lines (45 loc) · 851 Bytes
/
Copy pathfinalkey.java
File metadata and controls
54 lines (45 loc) · 851 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
final class A
{
int name;
}
// class B extends A
// {
// // --cant extend final class
// }
class C
{
public void show()
{
System.out.println("C show");
}
public final void cantshow()
{
System.out.println("only C show");
}
}
class D extends C
{
public void show()
{
System.out.println("D show");
}
// public void cantshow()
// {
// System.out.println("only D show");
// }
//--cant copy final methods
}
public class finalkey
{
public static void main(String[] args)
{
final String name = "Aayan";
//name = "trying to change"; --cant change final var
System.out.println(name);
C obj1 = new C();
obj1.show();
obj1.cantshow();
D obj2 = new D();
obj2.show();
}
}