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 |
What is an infinite loop?
How many types of syncronization?
What is escape analysis algorithm in JVM and how garbage collection actually worked n how it transfer the objects from one kind of space to other?
What are different types of Exceptions?.
What is meant by class loader and how many types are there?
What are three types of loops in java?
v-model life cycle
List interface?
How Applets & Servlets will communicate with each other?
How do you implement polymorphism in our day to day life?
What is the syntax and characteristics of a lambda expression? Explain
Are strings immutable in java?