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 |
Explain the difference between transient and volatile in java?
What is a condition in programming?
What is the method in java?
What is arraylist e in java?
What is flush buffer?
Why are generics used?
Is linked list a linear or non-linear data structure?
0 Answers Akamai Technologies,
What is files manifesting?
How are variables stored in memory?
int a=1,b=10; System.out.println(a+b--);
Explain jvm, jre, and jdk?
What is nan inf?