why an outer class cannot be declared as private?
Answers were Sorted based on User's Feedback
Answer / ravi kumar
private class PrivateClass //You cannot use private here
{
}
class TestClass //This is valid
{
}
}
This is because, in above example, if you declare PrivateClass as private then it's private to what? As Vijay said, it is of no use. So, intellisense intelligently doesn't show 'private' .
also another thing that private class can not be instantiate means u can not create object that class then what will be use of that class
| Is This Answer Correct ? | 5 Yes | 0 No |
Answer / Vikalp Chauhan
An outer class cannot be declared as private because a private outer class would restrict access to its methods and fields only within the same package. However, a private inner or nested class can be defined, which is only accessible within its enclosing class.
| Is This Answer Correct ? | 0 Yes | 0 No |
What are the access modifiers in java?
Is array a class?
What is a singleton factory?
Q) I have a ArrayList object, in that object i have added 5 integer values, 5 float values, 5 string values. Now question is how can delete particular type of data ( i.e all int values or all float values or string values) in that list object at a time?
Define immutable object?
Explain the difference between the Boolean & operator and the && operator?
Which software is used for java programming?
What is hasnext in java?
What does string [] args mean?
Which containers use a FlowLayout as their default layout?
What is a variable simple definition?
Why set do not allow duplicates in java?