can you create interface instance ?
Answer Posted / akthar
No,we can't create an object to an interface...as told uday he create a anonymous class same as Test interface ..if we remove the interface and method it is working ....so t doesnot act as object to an interface it acts as an anonymous class object...so it invoking its anonymous method..
class Main
{
public static void main(String[] args)
{
Test t=new Test()
{
public void wish()
{
System.out.println("output: hello how r u");
}
};
t.wish();
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Why local variables are stored in stack?
what is difference between equals and ==?
What is concurrent hashmap and its features?
Does java return by reference?
Why do we use regex?
What is a function argument in java?
What is java english?
What is a substitution variable?
What is compiler and what its output.
Why do we need data serialization?
What is the maximum size of byte array in java?
What is string example?
Give example to differentiate between call by value and call by reference.
Can a variable be local and static at the same time?
What technique can be employed to compare two strings?