compiler-design-eth/javali_tests/HW3/OkInheritanceFields.javali

31 lines
326 B
Text
Raw Normal View History

2020-01-15 22:32:25 +01:00
/* Test that fields are inherited */
class A {
int foo;
}
class B extends A {
int bar;
}
class Main {
void main() {
A a;
B b;
a = new A();
a.foo = 1;
write(a.foo);
a = new B();
a.foo = 2;
write(a.foo);
b = new B();
b.foo = 3;
b.bar = 4;
write(b.foo);
write(b.bar);
}
}