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

List primitive java types?

1094


What does || mean in code?

1101


What is the role of garbage collector in java?

1016


How does multithreading take place on a computer with a single cpu in java programming?

1059


What is the instance of an object?

1269


What is a prefix function.write down a code to compute prefix function.

1109


What is map in java?

1051


How to sort numbers in java without array?

1040


Which number is denoted by leading 0x or 0x in java?

1099


Why is stringbuffer called mutable?

1044


how would you implement a thread pool? : Java thread

969


What is the main function in java?

1110


Is it possible to cast an int value into a byte variable? What would happen if the value of int is larger than byte?

998


What is floor math?

1072


What is the argument in java?

988