28 lines
338 B
Text
28 lines
338 B
Text
|
// access a field from a class and a superclass (also includes hidden fields)
|
||
|
|
||
|
class Main {
|
||
|
void main() {
|
||
|
C1 c1;
|
||
|
C2 c2;
|
||
|
C4 c4;
|
||
|
c1 = new C1();
|
||
|
c2 = new C2();
|
||
|
c4 = new C4();
|
||
|
c1.a = 5;
|
||
|
c2.a = 6;
|
||
|
c4.a = false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class C1{
|
||
|
int a;
|
||
|
}
|
||
|
|
||
|
class C2 extends C1 {}
|
||
|
|
||
|
class C3 extends C2 {}
|
||
|
|
||
|
class C4 extends C3 {
|
||
|
boolean a;
|
||
|
}
|