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 |
who was the founder of java
32 Answers CTS, HCL, ProKarma,
Can an object be garbage collected while it is still reachable?
What is the string function?
If there are two notepad opened and working on it . is this a process or thread? computer based Live Example to differentiate between Thread , Process , and Multi tasking ?
where final and static variable stored?
What are instance variables?
Explain serialization and deserialization in java?
What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?
What do bitwise operators do?
How hashmap increases its size in java?
what is inner class in java?
what is Assertion?