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


Please Help Members By Posting Answers For Below Questions

What is meant by design patterns?

814


What is __ init __ functions?

807


Why string objects are immutable in java?

817


What is math in java?

844


Difference between java and javascript

837


how to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state? : Java thread

768


Are primitives objects?

802


How can you traverse a linked list in java?

909


When we should use serialization?

804


What are variable arguments or varargs?

800


What is floor math?

705


How many days will it take to learn java?

718


What is the file extension for java?

857


Which non-unicode letter characters may be used as the first character of an identifier?

810


Is void a type?

772