• 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

Abstract method instance variables

 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Trying to figure out this type of code :

About the instance variables of this class, they are private, so no subclass will see it, right ? The can not be marked abstract since they are instance variables, all the other methods are abstract , dont use those variables for anything, so , unless Im missing something , they would be there for nothing right ?
Any rules Im missing because those variables are part of an abstract class ?
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Giselle Dazzi:
Trying to figure out this type of code :

Any rules Im missing because those variables are part of an abstract class ?


Giselle,
I believe your conclusions are correct. However, there is nothing wrong with declaring private instance variables in an abstract class. Just know that without corresponding accessors and mutators (getter and setters) the private instance variables are indeed useless in this abstract class.
A more practical example of this abstract class might look like:

Now, concrete implementations will inherit these methods and the private instance variables are not wasted.
HTH,
Tim
 
Giselle Dazzi
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thx
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic