Re: Exception Handling
On Mar 10, 9:31 am, Lew <no...@lewscanon.com> wrote:
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 qu=
estion
> > 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 n=
ewsgroup.
Javas wrote:
>> > > }
> >
>> > > static class B extends A
>> > > {
>> > > void process() { System.out.pri=
ntln("B "); }
>> > > }
> >
>> > > public static void main(String[] args)
>> > > {
>> > > A a = new B();
>> > > a.process();
>> > > }
>> > > }
> >
>> > > Why does the above code results in a compilation error? since i=
t is
Lew:
> > When asking questions like this, saying "a compilation error" is w=
aaaaay 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 a=
ny
>> > > exception.
Lew:
> > The key is that it's a compilation error, not a runtime one. Th=
e 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-ti=
me
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?
I never advertised to you that I am smarter than
you. I guess you are trying to get personal.
#2: What wasn't cordial about my manner?
You could have just answered the questions and
stopped there, instead of worrying about whether's it my homework or
assignment work. Or atleast you could have suggested me to name the
class properly. But you chose the wrong path.
#3: What mistakes? Trying to help you, apparently.
You had some other intentions too other than
helping one alone.
Above all, I just wanted to convey it to you.
That's the reason why I sent it to you alone.
--
Lew