is it mandatory to deaclare all variables public static
fianl in interfaces?if i declare like in the below program,
public interface A
{
public static final int I=0;
int j=0;
}
in interface A,what is the difference between I,j?
Answer Posted / ramakrishna
generally if we want to access the variables(non-static)
which are present in the class we use the reference of that
class. we get the reference of the class after creation of
the object. but we can not able to create the object of the
interface if we define the non-static variables inside the
interface if we want to access it is not possible so if we
want to define the variables we should have to define the
variables as static.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is javac used for?
What do you understand by the term polymorphism?
What is a conditional statement explain with example?
What is nested interface?
Can we use a switch statement with strings?
What are the advantages of inner classes?
Can java cast null?
Can we override data members in java?
What does += mean in java?
Why we override equals() method?
Can we have multiple classes in single file ?
write a program that list all permutations of ABCDEF in which A appears before B?
Difference difference paint() and paintcomponent()?
What is the tradeoff between using an unordered array versus an ordered array?
What are the types of casting?