java exception q&&a – nontrivial

A minimum custom exception : “class e1 extends Exception {}”
Q: Where’s the constructor? where’s is the e1(String) constructor?
a: a constructor is needed for the exception obj’s “new” operation

q3: when an exception is thrown, control passes to…?

a1: wrap the exception-prone statements in a try-catch

A: constructor is the invisible e1(){super();} There’s no e1(String)
constructor in this case, since u didn’t define it.

q: is there a constructor for each exception obj?
A: i think so, including the no-arg

a4: on the heap

q1: how do u keep your method “alive” if u know an exception can be thrown
prior to a normal return?

a2: inside the exception obj and the exception type (ie the full class
name), but often there’s nothing inside the obj

q4: is exception obj created with new()? on the heap?

A3: exception handler for this particular (type of) exception

q2: there is specific information about each exception. who needs this
info? where is this info stored?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s