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 |
Why is the main method static?
what are the disadvantages of indexes in oracle?
0 Answers 3i Infotech, Wells Fargo,
Which is better ascii or unicode?
What is the purpose of assert keyword used in jdk1.4.x?
What is the use of a conditional inclusion statement in Java ?
What does mean in regex?
What is a JAR file?
What is the static method?
What is a singleton in genetics?
what do you understand by the term string with respect to java?
explain me with a code snippet about the generation and handling of null point exceptions.
how many access specifiers are available in java