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 javac in java?
I was asked to draw the class diagram for the below scenario which should obey OOPS concept. A Portal is to be developed for a school , which has 3 main divisions viz , Education , Admin & Trust. Each division has 2 sub divisions Kinder Garden & Higer Secondary.
Differentiate between class and structure.
What are thread local variables?
Can i have abstract class with no abstract methods?
What does function identity () do?
What comes to mind when someone mentions a shallow copy in java?
Can try statements be nested?
What is n in java?
we know that every java prog must follows OOPS Principles. Anybody can answer, HOW THE FOLLOWING PROGRAM FOLLOWS OOPS CONCEPTS i.e, Inheritance,Polymarphism,Encapsulation? class a{ public static void main(String args[]){ System.out.println("Hello World"); } }
what is predefined function in java?
What is consumer interface?