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 |
How to re-get an object that is collected by garbage collector?
Is boolean a wrapper class in java?
What is difference between checked and unchecked exception in java?
Can we cast any other type to boolean type with type casting?
What is java reflection api?
What are the four pillars of java?
What is a variable simple definition?
What is meant by inheritance and what are its advantages?
Explain the key functions of data binding?
0 Answers Akamai Technologies, Aspire, Impetus, Infogain, Tavant Technologies, Virtusa,
How to compare strings in java?
How large is a boolean?
how to know the total memory occupied by the objects in the ArrayList(Array list may contain duplicate objects)