so line 1 is answer...can you please explain
there is confusion between when a default constructor is declared?
we also know that...
If a class does not explicitly declare any, the Java compiler automatically provides a no-argument constructor, called the default constructor
I think that was at best confusing. You get a constructor in the class when you write one. The compiler creates a default constructor, so:-
shoeb sattar wrote:some one said when class is declared at that time default constructor is declared . . .
If you do not write a constructor, there is no constructor until the compiler runs and creates it.
You can see default constructors like this
javap -c Foo
Matthew Brown wrote:
shoeb sattar wrote:what would be the answer if no constructor was declared explicitly?
Well, in that case there'd be an implicit declaration of a no-arg constructor, but it would be misleading to say that any particular line declared it.
Well, I think you are right and closest to what I can understand..
I don't think such question would be asked in scjp exams?