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 happens when heap memory is full?
enlist some features of jdk.
How many types of classes are there in java?
What is an example of declaration?
Differentiate between array list and vector in java.
Can we cast any other type to boolean type with type casting?
What is foreach loop in java?
What causes memory leak in java?
Justify your answer that you can't define a method inside another method in java, if you can then how?
What are the advantages of compiled language?
What is generics in java interview questions?
Can constructor be protected in java?
How can we make sure main() is the last thread to finish in java program?
How do you replace all in word?
How do you check if two strings are equal in java?