When I write a class Widget.java
public class Widget {
int data;
String name;
}
will the compiler-generated constructo
It will be public Widget() {}
As classes visibility is public, it will always be a public constructor.
As said in JLS
If a class contains no constructor declarations, then a default constructor that takes no parameters is automatically provided:
It depends on your class visibility.The compiler uses the class visibility and generates a no-arg default constructor with the same visibility
It will be public
as the class visibility is public
public Widget() {}
If your class is public then the default constructor would be public so in your case, Since the Widget class is public its default constructor supplied by the compiler would also be public. See this