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 is number data type in java?

962


What is difference between adapter class and listener?

984


Explain the difference between hashmap and hashtable in java?

901


How do you achieve polymorphism in java?

957


What are 4 pillers of object orinted programming?

957


What is the common usage of serialization? What exceptions occur during serialization?

1068


What is java lang string?

955


What is the relationship between class and object?

997


What are the basic control structures?

943


What variables are stored in stack?

929


What is java Applet?

1048


What does t in java mean?

959


Why is a string immutable?

954


Can you override private or static method in java?

939


Write code to implement bubble sort in java?

957