What is the purpose of instance?

An instance variable reserves memory for the data your class needs . Let’s assume you want to add a place for a string or int variable. You can use an instance variable to reserve that memory for the lifetime of the object. Each object will receive unique memory for its variables.

Read more

Can you have a class in a class?

In Java, it is possible to define a class within another class , such classes are known as nested classes. They enable you to logically group classes that are only used in one place, thus this increases the use of encapsulation, and creates more readable and maintainable code.

Read more