This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Simple Question regarding Abstract class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Simple Question regarding Abstract class" Watch "Simple Question regarding Abstract class" New topic
Author

Simple Question regarding Abstract class

jo sim
Ranch Hand

Joined: Apr 24, 2006
Posts: 37
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

Joined: Jun 13, 2000
Posts: 3340
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.


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
jo sim
Ranch Hand

Joined: Apr 24, 2006
Posts: 37
can you instantiate an abstract class indirectly if not directly and if so how?
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
You can instantiate a concrete subclass of an abstract class.
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
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

Joined: Feb 03, 2004
Posts: 456
@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

Joined: Apr 24, 2006
Posts: 37
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.
 
Don't get me started about those stupid light bulbs.
 
subject: Simple Question regarding Abstract class
 
Similar Threads
Abstract Class
Object Hierarchy in Java
abstract class
private instance variable inside an abstract class
implementing abstract method in one class in another abstract class