-3

Could someone please tell which among ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED is the access modifier for default constructor in java?

In some of the asm example I saw ACC_PUBLIC but I could not find jvm specification related to this point.

Why there is not any need of package private access modifier?

nantitv
  • 3,539
  • 4
  • 38
  • 61
  • 1
    A constructor might be any of the four. And package level access is also known as "default" level access. – Elliott Frisch Feb 01 '16 at 11:29
  • I reformatted the question. Basically I meant default constructor – nantitv Feb 01 '16 at 11:31
  • http://stackoverflow.com/questions/13541386/default-access-modifier-for-a-java-constructor – MrSimpleMind Feb 01 '16 at 11:40
  • @MrSimpleMind: that question asks for an explicit constructor, not a default constructor. – Holger Feb 01 '16 at 13:03
  • @nantitv: there is no package private access modifier bit, because the absence of all other bits implies package private access, much similar to the source code. – Holger Feb 01 '16 at 13:05
  • @Holger but it says an explicit constructor, even though the title says default. Did you read the entire thread... ;) – MrSimpleMind Feb 01 '16 at 14:39
  • @MrSimpleMind: I’m not sure which question you are talking about now. The question you have linked is about *explicit* constructors, despite the misleading title. This question here is about *default* constructors, just as the title, the question and the accepted answer indicate. That’s why this is not a duplicate. One question is about explicit constructors, the other about the default constructor. – Holger Feb 01 '16 at 15:06
  • @Holger The linked question gives both answers, with Java Lang Spec references (JLS 8.8.9 and 6.6.1). So I find this as a duplicate . Seems that other agree this too... – MrSimpleMind Feb 01 '16 at 15:09

1 Answers1

2

The default constructor has the same accessibility as the class (see JLS §8.8.9).

Holger
  • 285,553
  • 42
  • 434
  • 765
wero
  • 32,544
  • 3
  • 59
  • 84