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?
Answers were Sorted based on User's Feedback
Answer / sreedhar a
As per interface definition all the member variables by
default are public static final. There is no difference
between I and j variables. JVM will consider the j variable
as public static final int j=0;
Note: variables declared in interface must be initialized
otherwise program will fail to compile.
| Is This Answer Correct ? | 7 Yes | 0 No |
Answer / 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 |
Tell me the latest versions in java related areas?
How many characters is 16 bytes?
How many functional interfaces does java 8 have?
Is Java Class Threadsafe ????? How to make Java class Thread safe??
What is the difference between post and put?
is there any function in java to make the text to blink?
how you will prevent method overriding?
What is the relationship between class and object?
What will be the output of round(3.7) and ceil(3.7)?
Is it possible to declare abstract class as final?What happens if we do so?
what is the life cycle of jsp?
What is method Overloading in the perspective of OOPS?