• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Page 129 - K&B 1.4 - Abstract Methods

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, it says on the page that because:

--------------------------------
abstract "methods must be implemented by a subclass, so they must be inheritable. For that reason:

Abstract methods cannot be private.
Abstract methods cannot be final.
--------------------------------

Can I assume then that abstract methods can be:

default, public, protected (since private is out of the question)
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I would think so. Because methods of an abstract class has to be implemented in any of its inherited classes. So having public, protected and default access should be permitted for abstract class -
 
Revathi Velu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok as it turns out, I tried the access modifiers for an abstract class and protected is not allowed -

Why ?? Anyone can help us here ??
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your original question was about methods.

Top Level classes can't be protected or private.
 
Revathi Velu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes thats right. Thanks -
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To the original question about abstract methods:

abstract methods must implemented(or you can say overriden) in the subclass.
So you can't declare "abstract final" or "private abstract".
private memebers are not visible to the subclasses they can't be overriden and final is something that can't be overriden.
so you can't use private and/or final with abstract methods.
Also, abstract methods can't be marked as synchronized, strictfp or native (these modifiers describes something about implementation !!).
I hope this will help.
 
Shanel Jacob
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all for the discussion and tips =)
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic