can you create interface instance ?
Answers were Sorted based on User's Feedback
Answer / anil
Uday..........Plz change ur name to James Gosling
Jr......dat suits u
| Is This Answer Correct ? | 0 Yes | 28 No |
Answer / udaykiran
Why Not?
Yes, Even we can create an instance of interface and
abstract class also.
just see this below simple example
Main.java
-----------
interface Test
{
public void wish();
}
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();
}
}
cmd> javac Main.java
cmd> java Main
output: hello how r u
in above case Test is an interface but i created the object
for that interface.
| Is This Answer Correct ? | 54 Yes | 92 No |
Difference between Application and Applet ?
Can an interface have a class?
How to sort the elements in HashMap
what is Vector class?
Name the methods in mouse listeners ?
What is merge sort in java?
What is a treemap in java?
What is the difference between member variables initialization and assignment in a constructor?
Which package is used for pattern matching with regular expressions?
What is an class?
can abstract class have constructor how can you achive this ?
What are field variable and local variable?