Tuesday, November 29, 2011

Can we make construtor STATIC?

You cannot make a constructor as STATIC, because if you use any access modifier in constructor compiler interprets it to be a method and expects a return type this class will not compile until you specify a return type, since compiler thinks it to be a normal method not a constructor.:A constructor can never be declared as static, because the role of a constructor is to initialize the object variables and static is never involved with the object so constructor cannot be static:Constructors cannot be declared static, and so Java gives us a way to perform static initialization. To declare a static constructor, you use the keyword static followed by the body of the method you&
Category:Java Interview Questions

No comments:

Post a Comment