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 |
Why is a singleton bad?
Why do we need singleton class?
What is a blocking method in Java?
There are 2 classes, 1 LandAnimal and another WaterAnimal. There is another class Animal which wants to have the properties of both LandAnimal and WaterAnimal. How will you design this situation?
How many java versions are there?
What are the advantages of functions?
how to print the below in java? * * * * * * * * *
What is the purpose of a volatile variable?
How many bytes is a unicode character?
What is a line break?
What are abstract classes and anonymous classes?
0 Answers Flextronics, Thomson Reuters, Virtusa,
What is class forname used for?