Tuesday, November 29, 2011

Core Java Interview Questions :How does the Java default constructor be provided?

If a class defined by the code does not have any constructor, compiler will automatically provide one no-parameter-constructor (default-constructor) for the class in the byte code. The access modifier (public/private/etc.) of the default constructor is the same as the class itself.:when we are not create any constructor then java take itself default constructor as(public,private,etc.)class.:but if you are providing the parameterized constructor u must provide the default constructor as well otherwise the complier will complain.....:The statement "but if you are providing the parameterized constructor u must provide the default constructor as well otherwise the complier will complain" is wrong. The compiler will not complain if you do not provide the default constructor with parameterized. But the user will not be allowed to create an object with the default constructor

No comments:

Post a Comment