This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Dear Community, I wanna querry about the workin of constructors:- 1. Will a constructor fires itself(execute itself, i mean) if there is no object of the class...e.g a simple program of "hello World" ...i believe that although there is no object required for the miraculous output of hello world...but the class still do have a constructor...or isn't it! What will be the nature of this constructor...? Regards Azam Bukhari email@example.com
The compiler gives you a default constructor for every class, with this caveat: if you don't define ANY constructors the compiler will generate one for you and intialize all the prroperties to null or zero, depending on their type. If you do define your own constructors, and you should, then YOU must define the default constructor, also known as the "no argument constructor." The compiler does it this way because the presence of any programmer defined constructors indicates the programmer does not want the default constructor. So, if you define your own constructors, and also want the no argument constructor, then you must re-define the no argument constructor. Pete ------------------ PAS firstname.lastname@example.org 2b | | !2b