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 difference paint() and paintcomponent()?
Program to print 1 1 2 1 2 3 1 2 3 4 like that
What is the middleware?
In a container there are 5 components. I want to display the all the components names, how will you do that one?
What is a numeric digit?
can we write two same methods in outer class and innerclass.
Can we inherit a class with private constructor?
Is math an abstract class in java?
write the hierarchy of component class?
How can you read an integer value from the keyword when the application is runtime in java? example?
What are the differences between graph and tree?
What is a memory leak in java?