can we create instance for interface in java?

Answers were Sorted based on User's Feedback



can we create instance for interface in java?..

Answer / jyotisubhra ghosh

You can not instantiate an interface,however, u can create
its reference variabe.

You can just assign an object of a class (implementing the
interface) to the reference variable of the interface.

Is This Answer Correct ?    50 Yes 1 No

can we create instance for interface in java?..

Answer / guru

interface call2
{


void get1();
int a=8;
}


interface call extends call2
{


void get();

}



class interex implements call,call2
{

public void get()
{

System.out.println("hi");

}
public void get1()
{System.out.println("hsfwsi");}
}


class interex1
{
public static void main(String s[])
{
call e=new interex1();



e.get();
e.get1();

System.out.println(e.a);
}
}

second pgm
-----------
interface call2
{


void get1();
int a=8;
}


interface call extends call2
{


void get();

}



class interex implements call,call2
{

public void get()
{

System.out.println("hi");

}
public void get1()
{System.out.println("hsfwsi");}
}


class interex1
{
public static void main(String s[])
{
call e=new interex();



e.get();
e.get1();

System.out.println(e.a);
}
}

Is This Answer Correct ?    14 Yes 7 No

can we create instance for interface in java?..

Answer / venkateswararao

No,we cant create an instance if an interface in java , but
we can create a reference of an interface and we can
assign the object of a class to that interface reference.

Is This Answer Correct ?    6 Yes 0 No

can we create instance for interface in java?..

Answer / rani

yes

Is This Answer Correct ?    1 Yes 10 No

Post New Answer

More Core Java Interview Questions

How can you debug the Java code?

6 Answers   BirlaSoft,


What is advantage of java?

0 Answers  


What is an 8 bit word?

0 Answers  


why java does not have operator overloading?

2 Answers  


Does set allows null in java?

0 Answers  






What are the important features of Java 10 release?

0 Answers  


Explain differences between checked and unchecked exceptions in java?

0 Answers  


what is the diff between Servletcontext and servletconfig?

5 Answers  


How do you implement polymorphism in our day to day life?

0 Answers   Cap Gemini,


Explain about member inner classes?

0 Answers  


What are scalar data types?

0 Answers  


why do we use interface in java?

5 Answers  


Categories