Results 1 to 4 of 4
- 05-25-2009, 01:08 PM #1
Member
- Join Date
- Mar 2008
- Posts
- 16
- Rep Power
- 0
Invoking a superclass version of a overridden method
Hi all,
I am currently going through an example on the above topic (see subject) and with this comes a snippet of code,
Now as far as I can see this example shows super being used to invoke an overridden method i.e. the Boxer method. I have added these print statements to emohasise what method is being used but it doesn't print, does anyone know how I can emphaises this example with these simple print statements? So that I print a statement when we use superXML Code:class Boxer extends Dog2 { public void printYourself () { super.printYourself(); //Invoke the super class (Dog2) //then do Boxer specific work here System.out.println("You have just printed your sub-method!!"); } } public class Dog2{ public void eat() {} public void printYourself() { } public static void main(String [] args) { } }
Thanks
- 05-25-2009, 01:11 PM #2
Hi,
put S.O.P inside printYourself meth of Dog2 class to make sure that super is calledRamya:cool:
- 05-25-2009, 01:27 PM #3
Member
- Join Date
- Mar 2008
- Posts
- 16
- Rep Power
- 0
Hi Ramya,
I have just attempted this but it doesn't print?
Where in the printYpurself method does it go?Java Code:class Boxer extends Dog2 { public void printYourself () { super.printYourself(); //Invoke the super class (Dog2) //then do Boxer specific work here } } public class Dog2{ public void eat() {} public void printYourself() { System.out.println("You have just printed your supermethod!!"); } public static void main(String [] args) { } }
Sorry as you cann tell I am a beginner : )
- 05-25-2009, 01:33 PM #4
Similar Threads
-
Invoking Servlet from SWT application
By wolve634 in forum SWT / JFaceReplies: 1Last Post: 03-30-2009, 11:35 AM -
invoking javascript on in jsp
By pankaj_salwan in forum JavaServer Pages (JSP) and JSTLReplies: 3Last Post: 12-12-2008, 04:54 PM -
Graphic settings being overridden?
By sjchase in forum New To JavaReplies: 0Last Post: 01-16-2008, 11:27 PM -
Invoking superclass methods... how?
By rhobincu in forum New To JavaReplies: 7Last Post: 08-09-2007, 03:10 PM -
invoking method and output questions
By bluekswing in forum New To JavaReplies: 1Last Post: 08-06-2007, 06:36 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks