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


Please Help Members By Posting Answers For Below Questions

How do you add an arraylist to an array in java?

507


Difference between association, composition and aggregation?

555


What is generic class?

644


define polymorphism in java

632


Can we call virtual funciton in a constructor ?

1770






Is 0 true or false?

510


What are inner classes or non static nested classes in java?

705


What is array command?

553


Explain the difference between association, aggregation and inheritance relationships.

549


What is the loop in java?

568


What is included in core java?

579


What is final variable?

495


What do you mean by data type?

543


Why java is considered as platform independent?

588


What is native method in java?

561