+ 6
Is public keyword is optional in java
if we declare any class or method with with public has same meaning without using public key word eg:- public class Name { } or class Name { } is both have same meaning
4 Respuestas
+ 2
No,the default visibility is package-private.That stricter than public.
It reachable for the classes from the same package.
Here is the documentation:
https://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html
+ 1
No!!!
0
Different.
A class declared without public can be called only within the same package.
Let's create two classes in two diffierent packages as following.
package1.ClassA (with public)
package2.ClassB (without public)
Try to call ClassA from classB, then classB from classA.
You may find the defference.
0
no, a class variable without public keyword has only scope within a class.