I recently took a programming quiz and missed the following question:
Which of the following are not allowable modifiers for a class?
Choose at least one answer.
A. public
B. private
C. protected
D. abstract
E. final
F. static
I chose protected and static and got the question wrong with half credit. The course is online and my instructor has not gotten back to me about this question, so I was wondering what the correct answer is.
For a top-level class, you can't use private
, protected
, or static
.
For a nested class, all of those modifiers are allowed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.