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 are uses of Hash Code?
What is the point of polymorphism java?
What is the declaration statement?
How do you check if two given string are anagrams?
Can private members of a base class are inheritable justify?
How do you remove duplicates in java?
there are some duplicate values in ArrayList, how U'll get that array with out duplicate?
Write a program to find maximum and minimum number in array?
java program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.
What is the integer of 16?
How to instantiate static nested classes in java?
Variable of the boolean type is automatically initialized as?