private, protected Access Modifiers with a class
Why cant we use private and protected access modifiers with a class?
Thanks.
Why cant we use private and protected access modifiers with a class?
Thanks.
You want a class to have two different access modifiers?
Care to explain how that is supposed to work.
I dont want a class to have two access modifiers at a time. It's this way what I want.
private class Sample{}
( or)
protected class Sample{}
Top level calsses can only have public or default access (BTW, I can't think of a reason to use protected or private... can you ?)
The access modifiers protected and private pertain only to member classes (as already mentionned above.)
a class can not be private if we declare like that the error will be modifier private not allowed here. So the outer class can't be declared as private.
Private means "only accessible in the defining class." What's the defining class in a top-level class? There is none. Private would be meaningless.
And if you could have a top-level private class, how would you ever use it?