diff between abstract methods and interfaces with programing
(code) example?
Answer Posted / karthik
abstract class A
{
protected abstract void show();
}
public class xx extends A
{
protected void show()
{
System.out.println("karthik ok");
}
static void main(String aa[])
{
xx ob=new xx();
ob.show();
}
}
But in Interface
interface A
{
protected abstract void show();
}
public class xx implements A
{
protected void show()
{
System.out.println("karthik ok");
}
static void main(String aa[])
{
xx ob=new xx();
ob.show();
}
}
modifier protected not allowed here
protected abstract void show(); in Interface
Because Default public method
But in Abstract class we can have protected
interface A
{
int x;//Error we should need initial value
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What are different types of arrays?
How do you calculate square roots?
What is difference between classpath and path variables in java?
When is an object subject to garbage collection?
What is the different between get and post?
Why are arrays useful in java?
What is singleton class in ruby?
Which package is imported by default?
How many bits are in a sentence?
Difference between Linked list and Queue?
What is a flag and how does it work?
Why to use nested classes in java?
How do you check if an arraylist is not empty?
How can we break singleton in java?
What is OOP Language?