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
Can you have two constructors in java?
How to declare objects of a class ?
What is another word for methodology?
What is string example?
What is the difference between equals() and?
What is the syntax and characteristics of a lambda expression? Explain
What do you mean by byte code?
What is difference between calling start() and run() method of thread?
Can we have more than one package statement in the source file?
What is an immutable class? How to create an immutable class?
worst case complexities of Quick sort and Merge sort.
What is dot operator?
explain autoboxing in java?
Differentiate between static and non-static methods in java.
What does void * mean?