Click to See Complete Forum and Search --> : Is it possiblr to cast an object asan abstract class
tedpgh
03-19-2006, 07:55 AM
in a currrent assignment, I've been told that I need to cast an object as an abstract class. I didn't think that was posssible. AM I wrong?
I would appreciateany feed back.
Thanks,
Ted
felgall
03-19-2006, 12:56 PM
An abstract class is one that can only be used as the base for defining other classes. You can't have objects belonging to or cast as an abstract class because there is at least one method that is not yet defined.
Overkill
03-19-2006, 10:23 PM
Unless they mean creating a sub class of the abstract class? :|
Mr. Ram
03-20-2006, 01:49 AM
Have a look on this example :-
abstract class abs
{
abstract void disp();
}
public class abss extends abs
{
public void disp()
{
System.out.println("disp");
}
public static void main(String args[])
{
abs ob = new abss();
ob.disp();
}
}
Overkill
03-20-2006, 04:56 AM
Mr. Ram:
That is so strange, it casts itself down if the current object is abstract.
tedpgh
03-20-2006, 08:07 AM
Thanks!