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
What is an error in java?
How does remove work in java?
What are the various access specifiers in java?
Which class cannot be a subclass in java?
What is difference between char array and string?
What is better- service oriented or batch oriented solutions?
What is meant by method?
Can we use different return types for methods when overridden?
What is a dot notation?
How is string immutable in java?
How do I start learning java?
What about abstract classes in java?
What is lazy initialization in java?
Why volatile is used in java?
What is the meaning of flag day?