-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFinal.java
More file actions
61 lines (38 loc) · 979 Bytes
/
Final.java
File metadata and controls
61 lines (38 loc) · 979 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
public class Final {
public static void main(String[] args){
final int a = 10;
System.out.println(a);
// a = 20; // This is not permitted!
Base B = new Base();
B.msg();
Derived D = new Derived();
}
}
class Base {
Integer a = 10;
public final void msg(){
System.out.println("This is the msg() method! from Base class ");
}
}
class Derived extends Base {
// This is not permitted!
// @Override
// public final void msg(){
// System.out.println("This is overrided Method!");
// }
public Derived(){
System.out.println("Derived class is created!");
}
}
final class Base1 {
public Base1(){
System.out.println("Base1 is created!");
}
}
// Following extends are not permitted!
// class Derived2 extends Base1 {
//
// public Derived2(){
// System.out.println("Derived2!");
// }
// }