Java help

Joined
Oct 4, 2018
Messages
1
Reaction score
0
hii, i hava started to learn java before some days, I have the question that, what will happen if we do not put the public keyword before the class name????
 
Joined
Apr 25, 2017
Messages
251
Reaction score
33
public, protected and private are access modifiers. Public means that the subject may be accessed by any class, protected by subclass, private by the class itself, no modifier means "package protected", so the subject may be accessed by classes from the same package.

Subject is class, method, member variable.


Answer get from https://stackoverflow.com/a/16779279/5156075
 
Joined
Dec 10, 2020
Messages
10
Reaction score
1
hii, i hava started to learn java before some days, I have the question that, what will happen if we do not put the public keyword before the class name????
Hii Jeetu,
The public is access modifiers, every class has some access modifiers they are public, private, protected, and default. Private and Protected access modifiers are not used by the class.
Then you can use any access modifier otherwise it will catch the default access modifier (if you not use any keywords).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top