Difference between a public and a non-public class

What is the difference between a public and a non-public class?

A class with access specifier ‘public’ can be accessed across the packages. A package is like a folder in GUI based operating systems.
For example, the “public class String” class is a public class which can be accessed across the packages.

A non-public class is a class without public access specifier. A class without access specifier or with “protected” access specifier is called non-public classes.

If a class is specified protected access can be accessed in other packages but only by the subclasses. The class without access specifier can be accessed only within the package.
What is the purpose of the Runtime class?
Purpose of the Runtime class - The java runtime system can be accessed by the Runtime class...
What is the difference between a static and a non-static inner class?
Static and a non-static inner class - Like static methods and static members are defined in a class, a class can also be static...
Difference between the String and StringBuffer classes
Difference between the String and StringBuffer classes - String class is immutable. The characters of string objects can not be changed / modified...
Post your comment