can you create interface instance ?
Answer Posted / 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 |
Post New Answer View All Answers
what are Hostile Applets?
What is the this keyword?
What causes memory leak in java?
List two java ide’s?
What is the primary benefit of encapsulation?
Which object oriented concept is achieved by using overloading and overriding?
Explain the importance of thread scheduler in java?
What do you understand by copy constructor in java?
How many bytes is a unicode character?
List some oops concepts in java?
What is set in java?
How can we make copy of a java object?
What is the purpose of the finalize() method?
What are the major advantages of internal iteration over external iteration?
Why isn’t there operator overloading?