Explain a possible implementation technology for Java classes and objects

A regular grammar
March 22, 2023
Algol-60 call-by-name can be modelled by passing a function as a call-by-value parameter
April 1, 2023

Explain a possible implementation technology for Java classes and objects

2002 Paper 6 Question 6
Compiler Construction
Explain a possible implementation technology for Java classes and objects. Your
answer should focus on storage layout for objects and on how class variables and
methods are accessed—it is not necessary to explain access qualifiers such as public
and private. Illustrate your answer with the following program; in particular
indicate its eventual output.
class test {
public int n;
public static int s = 100;
public void f(int x) { System.out.println(“f1 ” + (x+n)); }
public static void main(String args[]) {
test p = new test();
test2 q = new test2();
test r = q;
p.n = 4;
q.n = 5;
q.m = 6;
r.n = 7;
p.f(p.s);
q.f(p.s);
r.f(q.s);
}
}
class test2 extends test {
public int n, m;
public static int s = 200;
public void f(int x) { System.out.println(“f2 ” + (x+n+m)); }
}
[20 marks]