did interface can implementation method ? i know its not
possible but my interviewer said its possible ..but how..?
any one have idea ???

Answer Posted / lakshmikanth

We can implement the method in the interface anonymously.

for example :

public class TestInterface {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
A o1= new A(){
public void f()
{
System.out.println("testing ....");
}
};
o1.f();
}

}
interface A
{
void f();
}

please let me know our concerns .

Lakshmiakanth.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the importance of finally block in exception handling?

529


What is meant by object oriented programming – oop?

535


Which package has light weight components in java programming?

666


What is void in java?

579


What is the purpose of using break in each case of switch statement?

559






Can two objects have same hashcode?

557


I want to re-reach and use an object once it has been garbage collected. How it's possible?

531


What are the differences between stringbuffer and stringbuilder?

531


How to convert string to char and vice versa?

506


What is rule of accessibility in java?

535


How many types of parsers are there?

536


What is the purpose of using the java bean?

558


What is the use of inner class?

534


Can a method inside a interface be declared as final?

516


Is a boolean 1 bit?

606