In java what is the difference between public class and ordinary class? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

In java what is the difference between public class and ordinary class?

Java programming

6th May 2021, 6:28 PM
santhosh Kumar
santhosh Kumar - avatar
3 Answers
+ 1
public class is accessible to all the other classes. What do you mean by "ordinary" class?
6th May 2021, 9:01 PM
Rohit
0
Ordinary class means just class
6th May 2021, 11:20 PM
santhosh Kumar
santhosh Kumar - avatar
0
By default, the "ordinary" classes visibility is package private, i.e. only visible for classes in the same package. src: https://stackoverflow.com/questions/12336814/is-a-class-private-or-public-by-default-in-java-and-c/12336827#:~:text=By%20default%2C%20the%20classes%20visibility,classes%20in%20the%20same%20package.&text=The%20class%20has%20no%20visibility,them%20to%20the%20compilation%20unit.
7th May 2021, 4:35 AM
Rohit