In Java, or other OOP languages-
class MyClass{
int a=5;
MyClass b=new MyClass();
void mymeth()
{
}
}
Here, creating an object of the class inside the class. When new object is created inside, it will create new members and class object(b here), which will again create members, objects? Won't this make a chain leading to infinite objects and variables? Dumb query.
It will lead to Stack Overflow Error.
Yes.
You run into a
StackOverflowError
(ironic, isn't it?) if you try to do that.