• Post Reply Bookmark Topic Watch Topic
  • New Topic

Constructors  RSS feed

 
akila sekaran
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Output is :


Why am I getting 0 as the output in this ?
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Constructors don't have return types, not even void.
 
Gaurangkumar Khalasi
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
akila sekaran wrote:


You have created a method not a constructor.
And by default instance variable of type int will be initialized with 0.
 
BalaMurali dhar
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
constructors does not have return nor void. You have create method. Not a constructor.By default instance variable int with initialized with zero only
 
akila sekaran
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh got it.. that was a silly question by me.. but still i gotta learn it.. thank you guys
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!