Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

re:constructors

 
ashish sood
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please help me with basic concepts of constructors like------>
can they be declared private???
can they be declared static???
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ashish sood wrote:
can they be declared private???
can they be declared static???


Did you try out writing a test class with constructors which fit these criteria? Did it compile? Did you get any errors?
 
ashish sood
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i did...
the program compiled successfully with "private" but failed with "static" modifier
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question answered :)

The next step is to think about situations where we might want private constructors, since it might seem counter-intuitive not to allow people to instantiate an instance of a class...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic