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 the purpose of format function?

708


Difference between string, string builder, and string buffer?

616


What is port number in java?

690


What does escaping a character mean?

626


Why map is used in java?

676






What does || || mean in math?

597


What is the use of a copy constructor?

656


What are the differences between c++ and java?

673


What is contractor means and methods?

654


What is a boolean structure?

655


What is a generic code?

623


What is double checked locking in singleton?

700


What is the difference between java applets and applications?

676


Is array primitive data type in java?

630


Enlist diffrent types of inheritance supported by java?

561