can you create interface instance ?
Answer Posted / arnold schwarzenegger
Yes we can create an instance of Interface but not directly but by using its subclass. Just check the below code
interface check
{
public void method1();
}
abstract public class B implements check
{
public static void main(String[] args)
{
check c = new check()
{
public void method1()
{
System.out.println("interface B m2");
}
};
c.method1();
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Which is better arraylist or vector?
Why do we need autoboxing in java?
How to write custom exception in java?
Define max and min heap, also the search time of heap.
what is the purpose of using rmisecuritymanager in rmi?
What are methods in java?
What is jit compiler ?
In java, how many ways you can take input from the console?
Can you write a java class that could be used both as an applet as well as an application?
Is java a utf 8 string?
What is the difference between Java Program Constructor and Java Program Method, What is the purpose of Java Program constructor Please Explain it Breafily?
What does percent mean in java?
Explain the concept of proper inheritance?
What are use cases?
When should you make a function static?