Java Reference
In-Depth Information
<class>..Dispatch:
The double period distinguishes this name from a method named Dispatch() .
The order of fields in an object is also important because a class inherits fields from a
superclass. In constructing the format of an object, first any inherited fields are allocated.
Then any newly defined fields are allocated. Java semantics require that space is allocated to
all newly dened elds, even those with the same names as inherited elds; the \overridden"
fields can are always available through casting an object to its superclass.
For each class, we also maintain a class template in the data segment, which among
other things may include a typical copy of an object of that class that can be copied to the
heap during allocation. We name this
<class>..Template:
For example, consider the following j-- code, which defines two classes: Foo and Bar .
publicclassFoo{
intfield1=1;
intfield2=2;
intf(){
returnfield1+field2;
}
intfoo(){
returnfield1;
}
}
classBarextendsFoo{
intfield3=3;
intfield1=4;
intf(){
returnfield1+field2+field3;
}
intbar(){
returnfield1;
}
}
Consider an object of class Foo , illustrated in Figure 6.15.
 
Search WWH ::




Custom Search