"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 Hierarchy of exception?
What is an immutable object? How do you create one in java?
What classes of exceptions may be caught by a catch clause in java programming?
Can I overload to string method
What is an exception in java?
How can we make copy of a java object?
What is boolean law?
What is primitive data type in java?
Difference between process and thread?
What are static initalizers in java ?
Explain java heap space and garbage collection?
What is string pool in java?
Is nan false?
Is there any case when finally will not be executed?
What are the advantages and disadvantages of object cloning?