• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Default Constructor doubt

 
Ranch Hand
Posts: 583
Firefox Browser Notepad Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


  • public Car() ,Is it programmer created default constructor ?
  • Is there any rule that constructor access modifier must be same as class access modifier to make it default constructor ?
  •  
    Bartender
    Posts: 4568
    9
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    That's a no-argument constructor. Not quite the same as the default constructor, which is what the compiler will add if the programmer doesn't provide one (though a default constructor always is no-argument).

    Which means the answer to the second question is "no". If a default constructor is added, though, I believe it does use the same access modifier as the class.
     
    saloni jhanwar
    Ranch Hand
    Posts: 583
    Firefox Browser Notepad Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Matthew Brown wrote:That's a no-argument constructor. Not quite the same as the default constructor, which is what the compiler will add if the programmer doesn't provide one (though a default constructor always is no-argument).

    Which means the answer to the second question is "no". If a default constructor is added, though, I believe it does use the same access modifier as the class.



    thanks Matthew
     
    reply
      Bookmark Topic Watch Topic
    • New Topic