0

I am completely lost right now. I don't get what the questions are trying to say and I want to know if someone can give me pseducode or just a small example on how to start them off because like I said I'm lost. I'm not trying to get answers or someone to do the work for me. I just need a general idea.

  1. (Order of catch Blocks) Write a program that shows that the order of catch blocks is important. If you try to catch a superclass exception type before a subclass type, the compiler should generate errors.

  2. (Constructor Failure) Write a program that shows a constructor passing information about constructor failure to an exception handler. Define class SomeClass, which throws an Exception in the constructor. Your program should try to create an object of type SomeClass and catch the exception that's thrown from the constructor.

2
Contributors
1
Reply
10
Views
3 Years
Discussion Span
Last Post by JamesCherrill
0

Hi ZK
It's hard to answer your post because we don't understand what your real problem is. Both tasks are really small and simple - maybe you are looking for some complexity or difficulty that's not actually there?

Eg. look at 2 again: "Define class SomeClass, which throws an Exception in the constructor. Your program should try to create an object of type SomeClass and catch the exception that's thrown from the constructor."
If you can explain exactly what's stopping you from doing that then hopefully someone here can fix that for you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.