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


Please Help Members By Posting Answers For Below Questions

Explain about sets?

555


What is complexity in java?

504


How do you pass by reference?

525


Considering notepad/ie or any other thing as process, what will happen if you start notepad or ie 3 times? Where 3 processes are started or 3 threads are started?

630


What 4 doubled?

524






What does a za z0 9 mean?

550


Is string a data type in java?

578


Why we used break and continue statement in java?

543


how can you take care of mutual exclusion using java threads? : Java thread

593


What does opcode mean?

516


What are the four integer types supported by java?

548


List the three steps for creating an object for a class?

504


What is object cloning in Java?

621


Describe the term diamond problem.

561


What carriage return means?

514