Re: Exception Handling
Please reply to the list.
Here is what you sent, with attributions:
Javas wrote:
>> > > public class Qn24 {
Lew wrote:
> > Say, I'm just taking a WAG here, but this wouldn't happen to be question
> > number 24 on your homework assignment, would it?
Javas wrote:
>> > > static class A
>> > > {
>> > > void process() throws Exception { throw new
>> > > Exception(); }
Lew wrote:
> > Do us a favor here on Usenet and please keep indentation down to a maximum of
> > four spaces per level. Eight is too wide for readability in a newsgroup.
Javas wrote:
>> > > }
> >
>> > > static class B extends A
>> > > {
>> > > void process() { System.out.println("B "); }
>> > > }
> >
>> > > public static void main(String[] args)
>> > > {
>> > > A a = new B();
>> > > a.process();
>> > > }
>> > > }
> >
>> > > Why does the above code results in a compilation error? since it is
Lew:
> > When asking questions like this, saying "a compilation error" is waaaaay to
> > vague. What is the error? *Copy and paste* the *exact* text of the error in
> > these cases.
Javas wrote:
>> > > always invoking class B's process() method which doesnt throw any
>> > > exception.
Lew:
> > The key is that it's a compilation error, not a runtime one. The fact that
> > a.process() is polymorphically calling B's version is a runtime
consideration,
> > not a compilation one. See markspace's answer.
> >
> > It becomes quite important in Java to keep compile-time and run-time
realities
> > separate in your mind.
Javas wrote:
Guruji! Don't try to act smart. Just try to share your views and
convey your requests in a cordial mannar. Hope you understand your
mistakes. I'll correct me from my next post onwards. Anyways, Thanks
for your answer.
#1: If you're so smart, why are you asking us for help?
#2: What wasn't cordial about my manner?
#3: What mistakes? Trying to help you, apparently.
--
Lew