• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt on Modifiers

 
balajee annamalai
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know that we cannot declare a class as both abstract and final this is beacuse both modifiers are opposite to each other.But i dont understand why cant we declare a class as private or protected is there any reason behind this?
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can, in fact, use any visibility modifier when declaring a class, be it package default, private, protected or public.
 
Nadeem Khan
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Jelle,
Can you please give an example where we can declare a class as "private".Because it is not allowed with class-declaration statement as far as i know.
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only in the case of an inner class definition.
I'm afraid my previous statement was lacking nuance.

 
Nadeem Khan
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok that explains
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic