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 run time allocation?

783


What a static class can contains?

919


Does substring start with 0?

748


Does string isempty check for null?

774


What is a parameter in matrices?

751


How do you compare values in java?

795


Is set sorted in java?

701


What does t in java mean?

743


What does java edition mean?

753


What makes a function well defined?

764


What is the purpose of a default constructor?

826


What is the file type?

808


Explain the difference between string, stringbuffer and stringbuilder in java?

760


Which is best ide for java?

780


What is main string [] args?

740