What is the visibility of a default constructor in Java11? This is different from what is the default visibility of a constructor.
Asked
Active
Viewed 586 times
0
-
1what's stopping you from checking it out yourself? – Ruslan Mar 16 '19 at 21:53
-
^ Maybe, but he's asking about Java 11 specifically. – Kars Mar 16 '19 at 21:55
-
@ErvinSzilagyi: There's a difference between "the access of a member declared without a specific access modifier" and "the access of a default constructor supplied by the constructor". – Jon Skeet Mar 16 '19 at 22:21
-
1Same as in all other Java versions. – Andreas Mar 16 '19 at 22:40
1 Answers
7
The visibility of the default constructor depends on the access modifier of the class, as stated in the java specification Chapter 8. Classes - 8.8.9. Default Constructor:
The default constructor has the same access modifier as the class, unless the class lacks an access modifier, in which case the default constructor has package access (§6.6).

Progman
- 16,827
- 6
- 33
- 48