Organizational Research By

Surprising Reserch Topic

Question:Can a top level class be private or protected?



asked Sep 13, 2013 in Java Interview Questions by anonymous
edited Sep 12, 2013
0 votes
24 views



Related Hot Questions

2 Answers

0 votes
No. A top level class can not be private or protected. It can have either "public" or no modifier. If it does not have a modifier it is supposed to have a default access.If a top level class is declared as private the compiler will complain that the "modifier private is not allowed here". This means that a top level class can not be private. Same is the case with protected.
answered Sep 13, 2013 by anonymous
edited Sep 12, 2013
0 votes
No. A top level class can not be private or protected. It can have either "public" or no modifier. If it does not have a modifier it is supposed to have a default access.If a top level class is declared as private the compiler will complain that the "modifier private is not allowed here". This means that a top level class can not be private. Same is the case with protected.
answered Sep 13, 2013 by anonymous
edited Sep 12, 2013

...