can you create interface instance ?
Answer Posted / tathagata
hi uday
I also tried this to call a interface of Collection and try
to instantiated but it is not working.
import java.util.*;
interface Test
{
public void wish();
}
class a implements Test
{
public void wish()
{
System.out.println("I am fine");
}
}
class Main
{
public static void main(String[] args)
{
Collection c =new Collection()
{
boolean isEmpty()
{
return true;
}
};
System.out.println(c.isEmpty());
Test t=new Test()
{
public void wish()
{
System.out.println("output:
hello how r u");
}
};
if(t instanceof Test)
{
System.out.println("t is a instance
of Test");
}
t.wish();
a oba=new a();
oba.wish();
}
}
But it is not working please explain.
Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Highest level event class of the event-delegation model?
What is stringwriter?
What is getkey () in java?
Can a class be defined inside an interface?
Define a package.
What is a qualifier in a sentence?
Write down program for following scenario. Use java coding standard. You have array list with some words in it..we will call it as dictionary….and you have a arbitrary string containing some chars in it. You have to go through each word of dictionary and find out if that word can be constructed with the help of chars from arbitrary string given. If you find the word print it else print none.
Can we change the scope of the overridden method in the subclass?
What is the generic class?
what happens when a thread cannot acquire a lock on an object? : Java thread
What are the differences between c++ and java?
Can you override private or static method in java?
What are the features in java?
Why is the main method static?
What is string manipulation?