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
Can you explain inner class.
What is java in simple terms?
What is var keyword ?
I want to control database connections in my program and want that only one thread should be able to make database connection at a time. How can I implement this logic?
What are scriptlets?
How do you reverse sort a list in java?
What are the main uses of java?
How to check if linked list contains loop in java?
What is formatted output?
What is bifunction in java?
What is an example of a constant variable?
whatis Home interface and Remoteinterface? with example?
How to perform linear search in java?
Why put method is idempotent?
What are annotations in java?