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 is meant by class?
What is the difference between declaration and definition in java?
What is the difference between comparison done by equals method and == operator?
Why volatile is used in java?
Why is java so popular?
What modifiers may be used with an inner class that is a member of an outer class in java programming?
Is oracle java 11 free?
What is a method header?
What is the difference between length and size in java?
What is abstract class? Explain
Explain about wait() method?
What are the advantages of java inner classes?
Can the interface be final?
Addition to previous section relative word 5th one was Putrid ans: rotten, also there was prob. in 1st section on bucket weight ans:10kg, also there was a prob. on train speed to find bridge length ans:800 mtrs.
How do you override a method in java?