In Java, an inner class is a class that is declared within another class or interface. To summarize, the same…