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????
 
Ad

Advertisements

Joined
Apr 25, 2017
Messages
179
Reaction score
23
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
 
Ad

Advertisements

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

Similar Threads

How to sort a CSV file with merge sort JAVA 7
Java problem 1
Iframe link overlapping text 4
Greetings 1
Designing an assignment problem 0
how to compile C file to be use on JNI 0
Hello, there! 8
Hello 4

Top