"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


Please Help Members By Posting Answers For Below Questions

What interface is extended by awt event listeners?

599


What is the difference between actual and formal parameters?

520


What are the topics in core java?

539


What is primitive array?

526


What are the methods available in a class?

589






What is collection class in java? List down its methods and interfaces.

534


Can we force garbage collector to run ?

574


What is constructor chaining in java?

589


How do you classify Dialog Box?

656


What is the difference between quicksort & mergesort? When should they be used? What is their running time?

658


How to check if linked list contains loop in java?

461


What is a nonetype?

567


Can we store variables in local blocks?

790


What is static and final keyword in java?

577


What is static keyword?

594