Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General 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