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 a method in coding?
How is hashcode calculated in java?
Explain the significance of class loaders in bootstrap?
What is autoboxing in java?
Why string objects are immutable in java?
What is tree node in java?
What are different types of inner classes ?
Which method returns the length of a string?
Which is better arraylist or vector?
Does windows 10 need java?
How many bits are used to represent unicode, ascii, utf-16, and utf-8 characters in java programming?
Can we call a non-static method from inside a static method?
What is the byte range?
What is a treeset class?
Can a abstract class be defined without any abstract methods?