Tutorspoint Java assignment experts provide member inner class homework help

Definition of Member inner class:

If we define a class in another class just as a member like variable and functions of those classes, then we call such a class as member inner class


Class outer1


Int x;

Class Inner1


Int I;

Public void fun In ()


System. Out. Prinln(“ inside fun In() of Inner 1”);


Fun Ou();


Public void fun Ou ()


X = x+1;

Inner in = new Inner1 ();

in .i =25;

System. Out. Prinln( in . i);


Public static void main (string args [ ])


+ Outer1. Inner1 oi = new Outer 1 (). New Inner 1 ();

Oi. Fun In ();



+, this is the syntax for creating objects of inner classes from static functions of outer classes. Since a class can contain static and non- static members, we may think of defining static members in the inner classes. But, rule says that non-static member inner classes should not have static members.


In the above program, if the main method is present in some other class test within the same path, even then we following the same (+) syntax for creating an object of the inner class. Thus we can create objects of the inner class from its outer class as well as from some other class which is outside the other class.

If we declare an inner class as private, then it is possible to create an object of inner class only in its outer class outside the outer class. It is not possible to create an object of the inner class. An inner class can extend any class which is available to its outer class. An inner class can extend an outer class but there is no use of it because, since the inner class is a member of the outer class.

Member Inner Class Homework Help