"we cannot create an object of interface but we can create
a variable of it".diacuss the statement with the help of
an example.
Answer Posted / ami singh
yes we can create a variable in inerface
and i will be constant
mans to say that hey will be static and final
inerface Xyz
{
public static final i = 12;
public static final j = 20;
}
class Amit implements Xyz
{
psvm(String [] args)
{
Xyz k = new Amit();
System.out.println("value of var1 " + k.i);
Sysem.out.prinln("value ofd var 2 " + k.j);
}
}
Thanks ami singh
(amitsing2008@gmail.com)
| Is This Answer Correct ? | 11 Yes | 0 No |
Post New Answer View All Answers
What is the difference between an interface and an abstract class?
Explain why wait(), notify() and notifyall() methods are in object class rather than in thread class?
Are arrays immutable in java?
Define max and min heap, also the search time of heap.
What is hash table in java?
Which container method is used to cause a container to be laid out and redisplayed in java programming?
Can java list be null?
Why is java not 100% pure oops?
Differentiate between the constructors and methods in java?
Why packages are used?
What is the use of accept () method in java?
What are different types of expressions?
What is the private method modifier?
Differentiate jar and war files?
Mention some interfaces implemented by linked list in java.