Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello .
is it possible to use new operator to define abstract class in another class something like this :
Java
abstract class x
{} 
class y {
x j=new x();

if not can tell me y ?
Posted
Updated 16-Dec-11 1:36am
v2

An abstract class cannot be instantiated, and that's why new doesn't work.
 
Share this answer
 
Comments
Balakrishnan Dhinakaran 16-Dec-11 7:40am    
my vote 5
No. Abstract classes cannot be instantiated, which means they cannot appear on the right hand side of a new operator.
You can however derive y from x by using the extends keyword and it will get the content that way.
 
Share this answer
 
No, it's not possible. This[^] is why.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900