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
What is procedure writing?
What does system out println () do?
What is the purpose of extern variable?
Variable of the boolean type is automatically initialized as?
Why is stringbuffer faster than string?
What is final keyword in java?
What are static methods?
How does singleton class work?
Can constructor be synchronized?
What are filterstreams?
Can arraylist contain null values?
How do you declare an array in java?
Explain hashset and its features?
How big is a 64 bit float?
Which package is always imported by default?