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
Define the term string pool?
What are the different types of inheritance in java?
Can a class have multiple superclasses?
Can you create an object of an abstract class?
What is method overriding in java ?
Explain what pure virtual function is?
Is java se free?
Explain about static imports in java?
Can we change the value of static variable?
What are access specifiers in java ?
What is balanced tree in java?
I want to persist data of objects for later use. What is the best approach to do so?
What is a memory leak in java?
What is java virtual machine and how it is considered in context of java’s platform independent feature?
Explain the difference between jdk, jre, and jvm?