This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

instance variables of Abstract Classes

 
Rajat Sarkar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abstract classes can have instance variables.But abstract classes can't never be instantiated.So where do the instance variables live in?
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajat Sarkar wrote:Abstract classes can have instance variables.But abstract classes can't never be instantiated.So where do the instance variables live in?


Abstract classes can have certain method implementations in it which are not abstract. Those methods can use those variables.
 
Omar Al Kababji
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in addition the instance variables could be used by the concrete class that extends the abstract class, for example if you have an abstract class named Person and you specify that it has an instance variables named Head, then if a class named Employee extends Person, it can acceess the head instance variable.





(peace)
 
Omar Al Kababji
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hope you got my point ;)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic