Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Why we should declare the variables as static and final in
interfaces?



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

Post New Answer

More Core Java Interview Questions

What is Overriding and how can it be used?

7 Answers   Consagous, Wipro,


Thanks A.jyotsna, Can u tell me differnce between abstract class and interface vikash

4 Answers  


How does queue work in java?

0 Answers  


How do you create an array in java?

0 Answers  


Different types of modifiers?

8 Answers   RoboCom,


How to add panel to a Frame?

5 Answers  


How can we create a synchronized collection from given collection?

0 Answers  


How does java pattern compile work?

0 Answers  


Difference between Primary key and unique key?

4 Answers  


By what default value is an object reference declared as an instance variable?

1 Answers   Wipro,


What do you understand by a Static Variable?

0 Answers   CGI,


What is the exact difference in between Unicast and Multicast object? Where will it be used?

0 Answers  


Categories