| |
|
Can we create a instance of abstract class object Question Posted on 19 Dec 2011 Home >> OOPS >> CLASS >> Can we create a instance of abstract class object |
As all of us know abstract method have not any implementation they have only declartion as in below example we have two constructor and one declartion of method sum nad below is another class where we try to create its instantiate and we will get error
Example:-
public abstract class absexample
{
public absexamplel()
{
}
public absexample(int i)
{
}
public abstract int sum(int i, int j);
}
public class classtwo
{
absexample a; // we can create object of abstract class
a = new absexample() //Here we get error we not instantiate object of abstract class.
}
All of us know abstract method are only for declartion not for implemention so calling such function is meaningless. So it is not allowed to instantiate abstract class | |
|
|
|
|