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

Have you ever used hashtable and dictionary?

582


What’s meant by anonymous class?

606


Difference between static synchronization vs. Instance synchronization?

568


What is the maximum size of byte array in java?

544


How do you find the maximum number from an array without comparing and sorting?

645






What is the importance of main method in Java?

579


What are peerless components?

626


What is a concrete classes? Is Java object class is concrete class?

522


Differentiate between == and equals().

602


Why do we need singleton?

546


What will happen when using pass by reference in java?

528


Why do we need data serialization?

551


what is singleton in java?

604


Why is stringbuffer faster than string?

495


What is singleton class and how can we make a class singleton?

661