Why non nested classes in java are not having marked as
protected access specifier
Answer Posted / udita bose
Sorry, but previous answer by Yayati Pavan does not answer the question. If that answer is true then there should not be a problem with a "protected" class, as "protected" keyword is wider than default one.
There are no protected class because it is unnecessary to have them. Access modifiers for classes determine 2 things
i) If a class can create instance of other class ?
ii)If a class can extend other class ?
Now, any class within the same package will be able to create an instance of "protected" class - this is true for default-accessor and public classes. No class outside the package will be able to create an instance of "protected" class - this holds good for default-accessor classes.
Again, for a "protected" class by its definition will be extendible by any class within its package - so is default-accessor class, and extendible for any class outside its package - so are all public classes.
Both of this reason nullifies the reason for a protected class.
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
What is purpose of applet programming?
how can i use a nonsynchronized hashtable?
What is independent and dependent variables in research?
What are conditionals and its types?
What is thread life cycle?
What is an infinite loop? How infinite loop is declared?
Can java hashmap have duplicate keys?
What is the difference between a constructor and a method?
why an outer class cannot be declared as private?
23. Storage space in java is of the form Stack Queue Heap List 24. What is java code embedded in a web page known as Applets Servlets scriptlets snippets 25. Which of the following attributes are compulsory with an
How to use Media tracker Class.
What is the difference between equals() and?
What is stringjoiner ?
Name few java util classes introduced with java 8 ?
What is the difference between processes and threads?