This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Java in General and the fly likes how can i get the referance of the abstract class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how can i get the referance of the abstract class" Watch "how can i get the referance of the abstract class" New topic
Author

how can i get the referance of the abstract class

maateen ashraf
Ranch Hand

Joined: Jan 08, 2001
Posts: 122
there is one abstract class
i want its referance how can i get it
thanX in advance
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
There can never be an instance of an abstract class, therefore there can be no reference to one. A reference to a class cannot exist at all (unless you mean a pointer to the classfile loaded in memory by the JVM, which you can't get at).


42
maateen ashraf
Ranch Hand

Joined: Jan 08, 2001
Posts: 122
hello,
Jeroen Wenting
i think that u couldn't understand what i actually asked.
anyhow we can have referance of abstract class but we cannot instentiate it directly but with the object of its child class....
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
It's quite possible to hold a reference to an object of a child class, and treat it as if it is an instance of the abstract class. This is just the same as holding a reference to an object and treating it as if it is a reference to an interface which it implements. Interfaces and Abstract classes can never be constructed, but it's quite possible (and useful) to have variables with such a type.
For example:

[This message has been edited by Frank Carver (edited February 09, 2001).]


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
jQuery in Action, 2nd edition
 
subject: how can i get the referance of the abstract class
 
Similar Threads
Difference between override and hiding
abstract classes
Graphics Class
Assignment operator return value
how can i intentiate an abstract class