COMP2396
Loading...
Searching...
No Matches
abstracts.java
Go to the documentation of this file.
1package chapter7;
2
3@SuppressWarnings("unused")
4final class dog extends animal {
5 int y;
6 @Override
7 void mustbeoverriden() {
8 System.out.println("dog");
9 }
10}
11
12@SuppressWarnings("unused")
13interface friendly {
14 void pet();
15}
16
17class bruh {
18 public final int x;
19 bruh() {
20 x = 1;
21 }
22}
23
24class test {
25 static int x=8;
26 test() {
27 x = 9;
28 }
29}
30
31public class abstracts {
32 static int z;
33 static {
34 z = 3;
35 System.out.println(z); // is called before main
36 }
37 public static void main(String[] args) {
38 animal[] a = new animal[10]; //support polymorphic array
39 //a[0] = new animal(); //error
40 a[0] = new dog();
41 a[0].mustbeoverriden();
42 a[1] = new cat();
43 final int x;
44 x=1;
45 System.out.println(x);
46 bruh b = new bruh();
47 System.out.println(b.x);
48 final int y;
49 {
50 y = 1;
51 System.out.println(y);
52 }
53 System.out.println(test.x);
54 test t = new test();
55 System.out.println(t.x);
56 Integer pp = 100;
57 System.out.println(pp);
58 }
59}
static void main(String[] args)