class ObjX { int i; String name; // This is the first constructor: only takes in one parameter for the name. public ObjX (String initialName) { name = initialName; i = 0; } // This is the second constructor: both name and ID are initialized. public ObjX (String initialName, int ID) { name = initialName; i = ID; } public String toString () { return "My name is " + name + " and my ID number is " + i; } } public class DynamicExample12 { public static void main (String[] argv) { // The old way: without using constructors. Will not compile ObjX x = new ObjX (); x.i = 5; x.name = "Mr. X"; System.out.println (x); // Use the first constructor. x = new ObjX ("Mr. X"); System.out.println (x); // Use the second one. x = new ObjX ("Mr. X", 5); System.out.println (x); } }