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

Simple Question regarding Abstract class

 
jo sim
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you have a private variable in an abstract class?
also Can you have a static variable in an abstract class? and why?
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes and Yes

An Abstract class will be part of a final class and as such can do everything a final class can with the exception of being instanciated directly.
 
jo sim
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you instantiate an abstract class indirectly if not directly and if so how?
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can instantiate a concrete subclass of an abstract class.
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An abstract class will be instanciated as part of the object creation process of any final class that extends it.


Give it a spin
 
Jan Groth
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@jo

pure curiosity - why don't you try yourself? don't get me wrong, it's good to post questions here, but in order to find out the answer to a "can i ..." question, trying out is perfectly okay.

if it comes to the "why..." part, people will be happy to help...

many greetings,
jan
 
jo sim
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for helping me out I wanted to know if there was a way to instantiate the abstract class but i guess there is no way. I wanted to know what is the meaning of explicit and implicit object casting? I cant seem to find resources on it can you provide me a link?
thanks for your help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic