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
Can we call a non-static method from inside a static method?
What is the significance of listiterator?
How to do a true java ping from windows?
Does substring create a new object?
What is the inheritance?
What is difference between arraylist and list in java?
What is a function in java?
Why set do not allow duplicates in java?
How many types of equations are there?
How to convert string to byte array and vice versa?
What is the difference between JDBC 1.0 and JDBC 2.0?
What is a methodologist?
What is the difference between member variables initialization and assignment in a constructor?
What is port number in java?
Why Java is not pure Object Oriented language?