Win a copy of Spring Boot in Practice this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

abstract method call

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have a piece of code that looks like this
abstract public class super
{
public void meth(){absMeth();}
abstract void absMeth();
}
public class sub extends super
{
protected void absMeth(){print something}
}
then when i run the meth method of sub nothing gets printed out shouldnt this work?
[ August 07, 2002: Message edited by: Gyutae Kim ]
[ August 07, 2002: Message edited by: Gyutae Kim ]
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gyutae,
Try this:

Hope this helps,
Michael Morris
 
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gyutae,
You have attempted to use the keyword "super" as a class identifier. You need to change the name of your class.
If you want to put both class declarations in the same file, then you need to make sure that only one is declared public.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
then when i run the meth method of sub nothing gets printed out shouldnt this work?
Yes, Gyutae, such a structure should work. You perhaps have an error in your code. What is the code that you're trying to compile and run?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic