Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Exception in constructor chaining

  Asked By: Mona    Date: Jan 10    Category: Java    Views: 583
  

I have a question for you all.
Help me pls

There are 5 classes A,B,C,D & E
A->B->C->D->E is the hierarchy.
A is the super class of all the classes.

suppose you are trying to construct an object of class E, so the JVM starts
constructing the objects starting from class A.
If an exception occurs when creating object C, what happns ?

how many objects will be created in the memory ?
which of them are elegible for GC ?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Chad Bradley     Answered On: Jan 10


If the exception  is not handled in your code the
default exception handler is called (which just prints
a stack trace) and the stack is unwound and te program
exits. Therefore, there is no need for garbage
collection.

 
Didn't find what you were looking for? Find more on Exception in constructor chaining Or get search suggestion and latest updates.




Tagged: