can we create instance for interface in java?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
What is gui programming?
What is difference between iterator access and index access?
string is immutable? right every one knows that, my question is it advantage or disadvantage making string immutable?
What is the final blank variable?
What method is used to know the status of Checkbox(i.e it is checked or unchecked)?
Why sleep()is in Thread and wait() in Object class? Why can't I have both in one class or vice versa?
What type of language is java?
class test { private static void main(String []adsf) { } } explain me that the above code is error or exception
How can we run a java program without making any object?
can java object be locked down for exclusive use by a given thread? Or what happens when a thread cannot acquire a lock on an object? : Java thread
What is cr keyboard?
what is the major difference between linkedlist and arraylist in java?