Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between Default & Zero Constructor

 
faisal usmani
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I am not sure but i think there is a difference between a zero argument constructor given by a developer and the default constuctor made by Java compiler if no constuctor is given inside a class .


Can anybody of you help in understanding the difference between the two .

thanks is advance

Look at all the sentences which seem true and question them.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you define one yourself, it can be public, protected, private, or default, and of course, it can contain arbitrary code. If you leave it up to the compiler to define one, it will be public if the class is public, or default-protected otherwise, and contain no code. But aside from that, there's no difference.
 
faisal usmani
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ernest , i got the point .


I have always depended on the kindness of strangers.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic