can we create a instance for intwerface?

Answers were Sorted based on User's Feedback



can we create a instance for intwerface?..

Answer / subhash

No.We cannot create instance for interface.But we can
create reference to an interface.We can implement the
interface by creating sub class(implementation class) and
creat instance to the sub class, then you can create
reference to the interface by assigning instance of sub
class to the interface reference variable.

Is This Answer Correct ?    8 Yes 0 No

can we create a instance for intwerface?..

Answer / uma

no.Interface is similar to class but they lack instance
variable, their methods are declared with out any body.
Interfaces are designed to support dynamic method
resolution at run time. All methods in interface are
implicitly
abstract, even if the abstract modifier is omitted.
Interface methods have no implementation;

Is This Answer Correct ?    2 Yes 0 No

can we create a instance for intwerface?..

Answer / amit kumar gautam

Though it is correct that interfaces are basically used for
obtaining the dynamic resoulution of the Method and they
usually can not be instantiated but it is also possible to
instantiate the same in case of anonymous classes and it
works fine.......


class Amit
{

void addCode()
{
Runnable rr=new Runnable()
{
public void run()
{
System.out.print("This is Amit")
}
};
Thread tt=new Thread(rr);
tt.start();

}
}

class Check
{
static public void main(String[]amit)
{
new Amit().addCode();
}
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

how cani read a command line argument?(usingfile object).

3 Answers  


what are the boundaries of jdk and jre?

0 Answers   CoreObjects,


What is the purpose of the file class in java programming?

0 Answers  


What do you mean by global variable?

0 Answers  


What are the advantages of java over cpp?

0 Answers  






What is the difference between serializable and externalizable interface?

0 Answers  


How to Create A Wapper Class in core Java and Why are Use in java?

2 Answers   Amdocs,


What is scope & storage allocation of static, local and register variables? Explain with an example.

0 Answers   IBS,


Which browsers work with java?

0 Answers  


Can subclass overriding method declare an exception if parent class method doesn't throw an exception?

0 Answers  


What is the difference between instanceof and isinstance?

0 Answers  


Is null a string or object in java?

0 Answers  


Categories