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?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What happens if we override private method?

953


Under what conditions is an object’s finalize() method invoked by the garbage collector?

1018


how many types of Inheritance?

1148


What is the difference between throw and throws in java?

1077


What is a singleton puppy?

957


What is skeleton and stub? What is the purpose of those?

1092


What is the difference between the paint() and repaint() methods?

1046


What is the final keyword in java?

1402


Can we force garbage collector to run ?

1041


In a class implementing an interface, can we change the value of any variable defined in the interface?

1066


How to display names of all components in a Container?

2921


What is an interface in java? Explain

1159


whatis Home interface and Remoteinterface? with example?

1988


Explain the purpose of garbage collection in Java?

1006


What is the use of singleton class?

950