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

Can abstract class have private constructor?

496


What is Java Shutdown Hook?

611


How to implement a multithreaded applet?

2201


What does java final mean?

522


What do you mean by compiler?

581






How to solve the problem of generating the unique hash keys with hash function?

1458


What is == mean?

553


What is JFC?

707


What is yield () in java?

480


Explain about fail safe iterators in java?

564


What is an escape character in java?

530


What is difference between iterator access and index access?

645


Write a program to reverse array in place?

586


What is unmodifiable collection in java?

508


What is formatted output?

509