This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Default Constructor doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Default Constructor doubt" Watch "Default Constructor doubt" New topic
Author

Default Constructor doubt

saloni jhanwar
Ranch Hand

Joined: Feb 09, 2012
Posts: 583



  • 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 ?


  • Tell the difficulties that i am difficult.
    Matthew Brown
    Bartender

    Joined: Apr 06, 2010
    Posts: 4240
        
        7

    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

    Joined: Feb 09, 2012
    Posts: 583

    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
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Default Constructor doubt
     
    Similar Threads
    about constructor
    constructor doubt
    constructor
    Creating objects using Reflection
    default constructor access