Results 1 to 2 of 2
  1. #1
    javaPower is offline Member
    Join Date
    Jun 2010
    Posts
    9
    Rep Power
    0

    Default access modifier in constructor

    if have a question. if i don't specify any access modifier in a constructor, does this mean that the constructor inherit the access modifier of the class?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,003
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by javaPower View Post
    if have a question. if i don't specify any access modifier in a constructor, does this mean that the constructor inherit the access modifier of the class?
    Nope, no access modifier means the default access modifier which is "package scope"; it means that only objects in the same package as your class may instantiate an object from your class. The class itself can be public which means that everybody (also outside of the package) can use an existing object of that class.

    kind regards,

    Jos

Similar Threads

  1. protected modifier ? Constructors
    By javanew in forum New To Java
    Replies: 6
    Last Post: 04-06-2010, 11:59 AM
  2. default access modifier
    By vishnugch in forum New To Java
    Replies: 1
    Last Post: 08-17-2009, 12:48 PM
  3. Regarding default access modifier?
    By makpandian in forum New To Java
    Replies: 2
    Last Post: 03-14-2009, 08:21 AM
  4. Replies: 1
    Last Post: 07-20-2008, 04:42 PM
  5. why we use public access modifier?
    By vichet in forum New To Java
    Replies: 1
    Last Post: 04-04-2008, 07:04 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •