Why we should declare the variables as static and final in
interfaces?
Answer / nc
It is automatic static and final even if you don't declare it.
Why? Because when a class implements these interfaces, these
variables must be able to be accessed by static and
non-static methods. Also as these variables are specific to
any class instances(i.e. at the same time many classes can
implement these interfaces), they must have the same value
across the implementing classes.
Also if you want to load the value of certain values at the
application start up and all implementing classes wants
these values unchanged, then these must be static and final.
So they are static and final.
| Is This Answer Correct ? | 15 Yes | 1 No |
whatis Home interface and Remoteinterface? with example?
Can we have try without catch block?
What is the difference between compiler and jvm?
What is meant by attribute?
What is a percentage sign called?
How to Sort Strings which are given in List and display in ascending order without using java api.
What do bitwise operators do?
How many types of exception can occur in a java program?
What is scope & storage allocation of global and extern variables? Explain with an example
What is the default value of byte datatype in java?
What is the r character?
What is compareto () in java?