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 |
If a method is declared as protected, where may the method be accessed in java programming?
What is a treeset class?
What is a nested list?
What are the types of classes in java?
How many types of constructors are used in java?
Can we use catch statement for checked exceptions when there is no chance of raising exception in our code?
Can string be considered as a keyword?
There is a Banking application. It has 2 types of account, Savings and Current. Write a method calculateInterest by passing an ArrayList of these account objects and calculate Interest accordingly. Write code for this situation
what are three ways in which a thread can enter the waiting state? Or what are different ways in which a thread can enter the waiting state? : Java thread
What is the size of a string in java?
What are the types of exceptions?
Write a java program to print fibonacci series?