compiler-design-eth/javali_tests/HW3/OkInheritanceFields.javali
Carlos Galindo 0afc86ceeb
Homework 3
2020-01-15 22:32:25 +01:00

30 lines
326 B
Text

/* 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);
}
}