[Advanced-java] OOP's Question
uddipan.bagchi at wipro.com
uddipan.bagchi at wipro.com
Fri Apr 27 08:49:35 PDT 2007
...Because that is the basic idea of method overriding. The method is actually invoked by a class of type A, and so it hunts for the method implementation first in Class A, then B, then C.
You need to do a lot of exercises like these to understand OOPs better...that's the only way to learn and know its exact behaviour. I've done it as well, a long time back though.
--------------------------
Sent from my BlackBerry Wireless Handheld
-----Original Message-----
From: advanced-java-bounces at lists.XCF.Berkeley.EDU <advanced-java-bounces at lists.XCF.Berkeley.EDU>
To: jaz at zukowski.net <jaz at zukowski.net>; advanced-java at lists.xcf.berkeley.edu <advanced-java at lists.xcf.berkeley.edu>
Sent: Fri Apr 27 15:27:17 2007
Subject: Re: [Advanced-java] OOP's Question
When I execute the program in Eclipse in debugging mode, I could see that the methodA() in A was being execute. But I could not follow exactly, that's why post the question.
> Date: Fri, 27 Apr 2007 10:14:01 -0400
> From: jaz at zukowski.net
> To: advanced-java at lists.XCF.Berkeley.EDU
> Subject: Re: [Advanced-java] OOP's Question
>
>
> This is easy to answer. It is called println. Add one to each of the
> methods and see which one is called.
>
> As far as Why.... Isn't that what homework is for, so you learn something?
>
> J
>
> Quoting "G.N.V. Jayprakash" <gnvjp at hotmail.com>:
>
> >
> > Hi,
> > I have a question in Object Oriented Programming:
> >
> > A extends B. B extends C. There is a public method methodA()
> > implemented in C. methodA() is also overridden in A.
> >
> > There is a flow starting from A from preProcessRequest()
> > implemented in A. preProcessRequest() is also implemented in B.
> >
> > Now preProcessRequest() in A invokes super.preProcessRequest(). The
> > control goes to the preProcessRequest() in B.
> > preProcessRequest() method implementation in B invokes methodA().
> >
> > Now the question is: Will the methodA() implemented in C will be
> > invoked or the methodA() implemented in A will be invoked? Why?.
> >
>
> _______________________________________________
> Advanced-java mailing list
> Advanced-java at lists.XCF.Berkeley.EDU
> https://lists.XCF.Berkeley.EDU/mailman/listinfo/advanced-java
________________________________
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it! <http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us>
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /lists/advanced-java/attachments/20070427/92981868/attachment-0001.html
More information about the Advanced-java
mailing list