| Author |
To prove that methods can be overriden but attributes cannot be.
|
Khuma Chhakchhuak
Greenhorn
Joined: Nov 30, 2012
Posts: 12
|
|
I have run the following code (JunkFirst.java)in eclipse to prove that only methods can be overriden. It is throwing runtime exception "stackoverflow". How do I correct the error?
|
 |
dennis deems
Ranch Hand
Joined: Mar 12, 2011
Posts: 808
|
|
|
You have an infinite recursion. In your definition of the class Child, you have an instantiation of that class. That means that any time you try to instantiate a new Child, that instance will instantiate a new Child, and then that instance will instantiate a new Child, and so and so on until the stack runs out of space.
|
 |
Khuma Chhakchhuak
Greenhorn
Joined: Nov 30, 2012
Posts: 12
|
|
|
Thanks Dennis.
|
 |
 |
|
|
subject: To prove that methods can be overriden but attributes cannot be.
|
|
|