Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
public abstract class Abs {


abstract void display(int a,int b);
void disp(){
System.out.println("hello");
}
}
abstract class help extends Abs{

}

class main{

public static void main(String[] args) {

Abs as= new Abs() {

@Override
void display(int a, int b) {
}
};

help h= new help() {

@Override
void display(int a, int b) {

}
};

}

}
Posted
Comments
Sergey Alexandrovich Kryukov 29-May-15 1:44am    
What would it mean, "created to a class"?
—SA

1 solution

Nothing happens. There is no such concept as "object created to a class". The question makes no sense, because runtime type of any object cannot be any abstract class. This is the purpose of this abstract class feature to prevent instantiation of such class.

In turn, the purpose of abstract class is to server as a base class for other classes, this way providing a common interface for the polymorphic set of objects. The objects in such set can be of different runtime types, and the code using then can be agnostic about their differences. This way different implementations of some methods can be hidden behind the facade of this base class. Such class can also be used as a base class of just one non-abstract time, for the purpose of hiding implementation detail from the user of the base class as a compile-time type.

Please see: https://docs.oracle.com/javase/tutorial/java/IandI/abstract.html[^].

—SA
 
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