Ans:
Inner Classes:
Declaring a class inside a class is called as an Inner Class.
In Java applications,Inner classes are able to provide the following Advantages.
1.Modularity
2.Abstraction
3.Share-ability
4.Security
5.ReUseAbility
1.Modularity:
If we declare an Inner class inside a class then that inner class is treated as a module of that
entity class.
Ex:
---
class Account
{
class StudentAccount
{
}
class EmployeeAccount
{
}
class LoanAccount
{
}
}
Like Comment Share
2.Abstraction: If we declare any variable or method inside an inner class then that variable and method will have scope up to the respective inner class only,which are not available to outside of that inner class. | |
| 3.Security: In Java applications,private keyword is able to improve security. In Java applications,it is not possible to declare a class as private but it is possible to declare an inner class as private.Therefore Inner classes are able to improve security. | |
| 4.Share-ability: In Java applications,static keyword is able to improve share-ability.In Java applications,it is not possible to declare a class as static but it is possible to declare an inner class as static. Therefore inner classes are able to improve share-ability. | |
| 5.ReUseAbility: In Java applications,inheritance is able to improve ReuseAbility.In Java applications,it is possible to extend one inner class to another inner class,so that,inner classes are able to improve ReuseAbility. | |