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 we convert stringbuffer to string?
What is an example of a keyword?
Why spring singleton is not thread safe?
Will the compiler creates a default constructor if I have a parameterized constructor in the class?
java Technical questions asked by JPMC
How do you convert bytes to character in java?
Name some classes present in java.util.regex package.
What is string syntax?
What is nan in java?
how we can make a write-only class in java?
What does flagged out mean?
What is listnode in java?
What is main string [] args?
What is anagram number?
What is the constructor?