Order of Constructors
|
Outline
|
// file: Order001.java // date: Oct 4, 2015 // Author: Nicholas Duchon // Purpose: demo constructor order calls System.out.println ("In no parameter constructor: Order001"); Order001 x = new Order001(); |
Comments
Output:In no parameter constructor: Order001 |
// file: Order002.java // date: Oct 4, 2015 // Author: Nicholas Duchon // Purpose: demo constructor order calls this ("a string"); System.out.println ("In no parameter constructor: Order002"); System.out.println ("In String constructor: " + s); Order002 x = new Order002(); |
Comments
Output:In
String constructor: a string |
// file: Order003.java // date: Oct 4, 2015 // Author: Nicholas Duchon // Purpose: demo constructor order calls static { System.out.println ("Order003 static initializer"); } // static initializer this ("a string"); System.out.println ("In no parameter constructor: Order003"); System.out.println ("In String constructor: " + s); Order003 x = new Order003(); |
Comments
Output:Order003
static initializer |
// file: Order004.java // date: Oct 4, 2015 // Author: Nicholas Duchon // Purpose: demo constructor order calls static { System.out.println ("Order004 static initializer"); } // static initializer { System.out.println ("\nOrder004 instance initializer"); } // static initializer this ("a string"); System.out.println ("In no parameter constructor: Order004"); System.out.println ("In String constructor: " + s); Order004 x = new Order004(); Order004 y = new Order004(); |
Comments
Output:Order004
static initializer |
// file: Order005.java // date: Oct 4, 2015 // Author: Nicholas Duchon // Purpose: demo constructor order calls Order005a z = new Order005a (23); static { System.out.println ("Order005 static initializer"); } // static initializer { System.out.println ("Order005 instance initializer"); } // static initializer this ("a string"); System.out.println ("In no parameter constructor: Order005"); System.out.println ("In String constructor: " + s); Order005 x = new Order005(); Order005 y = new Order005(); System.out.println ("\nIn int constructor Order005a: " + a); |
Comments
Output:Order005
static initializer |
// file: Order006.java // date: Oct 4, 2015 // Author: Nicholas Duchon // Purpose: demo constructor order calls Order006a z = new Order006a (23); static { System.out.println ("Order006 static initializer"); } // static initializer { System.out.println ("Order006 instance initializer"); } // static initializer this ("a string"); System.out.println ("In no parameter constructor: Order006"); System.out.println ("In String constructor: " + s); Order006 ma = new Order006(); Order006 mb = new Order006(); Order006b mc = new Order006b(); System.out.println ("\nIn int constructor Order006a: " + a); System.out.println ("In no parameter constructor: child class Order006b"); |
Comments
Output:Order006
static initializer |
// file: Order007.java // date: Oct 4, 2015 // Author: Nicholas Duchon // Purpose: demo constructor order calls Order007a z = new Order007a (23); static { System.out.println ("Order007 static initializer"); } // static initializer { System.out.println ("Order007 instance initializer"); } // static initializer this ("a string"); System.out.println ("In no parameter constructor: Order007"); System.out.println ("In String constructor: " + s); System.out.println ("\nCreating Order007: "); new Order007(); System.out.println ("\nCreating Order007: "); new Order007(); System.out.println ("\nCreating Order007b: "); new Order007b(); System.out.println ("In int constructor Order007a: " + a); Order007a z2 = new Order007a (2345); System.out.println ("In no parameter constructor: child class Order007b"); |
Comments
Output:Order007
static initializer |
// file: Order008.java // date: Oct 4, 2015 // Author: Nicholas Duchon // Purpose: demo constructor order calls Order008a z = new Order008a (23); static { System.out.println ("Order008 static initializer"); } // static initializer { System.out.println ("Order008 instance initializer"); } // static initializer this ("a string"); System.out.println ("In no parameter constructor: Order008"); System.out.println ("In String constructor: " + s); System.out.println ("\nCreating Order008: "); new Order008(); System.out.println ("\nCreating Order008: "); new Order008(); System.out.println ("\nCreating Order008b: "); new Order008b(); System.out.println ("In int constructor Order008a: " + a); Order008a z2 = new Order008a (2345); // Following is ILLEGAL because Order008 no parameter constructor // is private, hence hidden from the IMPLICIT super () call // first line of the following constructor // call in the first line of this constructor to the public // String constructor in Order008 super ("call to String constructor from Order008b"); System.out.println ("In no parameter constructor: child class Order008b"); |
Comments
Output:Order008
static initializer |