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 |
Is it safe to install java on my computer?
How does JAVA ClassLoader work?
What is purpose of keyword void?
what us Dyna action form?
4 Answers Aithent Technologies,
What is the benefit of lambda expressions?
Difference between Web-based applications,Client- Server applications and Distributed applications?
we have syntax like for(int var : arrayName) this syntax is to find whether a number is in the array or not.but i want to know how to find that number's location.
How dead lock situation occurs in java and how you can identify it?
What is an object in java?
where lives in jvm
What is the Vector class?
If a class is declared without any access modifiers, where may the class be accessed in java programming?