can you create interface instance ?

Answer Posted / shankar patil

You can't create an object without method implementations.
Anonymous inner classes allow you to do.

public interface MyInterface {
public void myMethod() ;
}

MyInterface myIntfObj = new MyInterface() {
public void myMethod() {
}
};

myIntfObj.myMethod();

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Does treeset use compareto?

530


What are the four integer types supported by java?

551


What is role of void keyword in declaring functions?

564


Is char a data type in java?

533


What is java english?

483






Difference between method overloading and method overriding in java ?

555


Can we have a method name same as class name in java?

571


What is meant by design patterns?

573


What are advantages of exception handling in java?

572


what do you understand by the term string with respect to java?

520


What is variable and rules of variable?

505


What is the use of isempty in java?

531


What is method overriding in java ?

646


Write an algorithm for quick sort?

606


Can we have try block without catch block?

576