EXECUTION
Creation of New Class Instances
12.5
3. This constructor does not begin with an explicit constructor invocation of
another constructor in the same class (using
this
). If this constructor is for a
class other than
Object
, then this constructor will begin with a explicit or
implicit invocation of a superclass constructor (using
super
). Evaluate the
arguments and process that superclass constructor invocation recursively
using these same five steps. If that constructor invocation completes abruptly,
then this procedure completes abruptly for the same reason. Otherwise, con 
tinue with step 4.
4. Execute the instance variable initializers for this class, assigning their values
to the corresponding instance variables, in the left to right order in which they
appear textually in the source code for the class. If execution of any of these
initializers results in an exception, then no further initializers are processed
and this procedure completes abruptly with that same exception. Otherwise,
continue with step 5. (In some early Java implementations, the compiler
incorrectly omitted the code to initialize a field if the field initializer expres 
sion was a constant expression whose value was equal to the default initializa 
tion value for its type.)
5. Execute the rest of the body of this constructor. If that execution completes
abruptly, then this procedure completes abruptly for the same reason. Other 
wise, this procedure completes normally.
In the example:
class Point {
int x, y;
Point() { x = 1; y = 1; }
}
class ColoredPoint extends Point {
int color = 0xFF00FF;
}
class Test {
public static void main(String[] args) {
ColoredPoint cp = new ColoredPoint();
System.out.println(cp.color);
}
}
a new instance of
ColoredPoint
 is created. First, space is allocated for the new
ColoredPoint
, to hold the fields
x
,
y
, and
color
. All these fields are then initial 
ized to their default values (in this case,
0
 for each field). Next, the
ColoredPoint
constructor with no arguments is first invoked. Since
ColoredPoint
 declares no
constructors, a default constructor of the form:
229






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved