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

Can the interface be final?

0 Answers  


What is qms certification?

0 Answers  


What is the difference between heap and stack memory?

0 Answers  


Given a singly linked list, how will you print out its contents in the reverse order? Can you do it with consuming any extra space?

0 Answers   Akamai Technologies,


What is runtime locatable code?

0 Answers   Cognizant,






What are wrapper classes in java?

0 Answers  


When a thread is executing a synchronized method , then is it possible for the same thread to access other synchronized methods of an object ?

0 Answers  


Explain methods specific to list interface?

0 Answers  


Explain about oops concepts.

0 Answers   Aditi Placement Service,


What is the access scope of protected access specifier?

0 Answers  


How do you override a private method in java?

0 Answers  


Can we use both this () and super () in a constructor?

0 Answers  


Categories