Difference between abstract class and interface
Answer Posted / cinda
1)abstact class may or may not include abstract methods(An
abstract method is a method that is declared without an
implementation )
Bt interface is a class with only signature of a
methods.class that implements an interface must implement
all of the interface's methods.
example for abstract class:-
public abstract class x {
int x,y;//definitions
void draw(){}//non abstract methods
abstract void YY();//abstract methods
}
example for interface:-
interface x
{
void sample(int y);//signature of amethod
}
2)abstract class can inherit from only one class(it doesnt
support multiple inheritance)
public abstract class x {
int x,y;//definitions
void draw(){}//non abstract methods
abstract void YY();//abstract methods
}
class y extends x{
void draw(){
....
}
but interface supports multiple inheritance
Interface interface1{
.....
}
Interface interface2{
.....
}
Interface interface3{
.....
}
public Interface x extends interface1,interface2,interface3{
}
In Interfaces , it was noted that a class that implements
an interface must implement all of the interface's methods.
It is possible, however, to define a class that does not
implement all of the interface methods, provided that the
class is declared to be abstract. For example,
abstract class X implements Y {
// implements all but one method of Y
}
class XX extends X {
// implements the remaining method in Y
}
In this case, class X must be abstract because it does not
fully implement Y, but class XX does, in fact, implement Y.
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Can you explain scriptmanager control?
Define cache coherency and how is it eliminated? : Dot net architecture
State the different levels of exceptional safety?
What is the difference between an event and a delegate?
What actually happes when you add a something to arraylistcollection ?
What is the procedure on hardware that converts the ascii value to binary? : .NET Architecture
How do we do authentications using atlas?
What is different about namespace declaration when comparing that to package declaration in java?
Explain cache? : Dot net architecture
What size is a .net object?
How can I create a application?
What is the purpose of Accordian in jquery? Where it can be used?
What is .net mobile utility controls. : Microsoft dot net mobile
Explain about appdomains?
Explain .net mobile input controls? : Microsoft dot net mobile