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

How java uses the string and stringbuffer classes?

1072


What exactly is java?

942


What is exception in java?

1085


How do you sort in ascending order in java?

872


What is linkedlist in java?

1001


What is an object in java and how is it created?

1055


why would you use a synchronized block vs. Synchronized method? : Java thread

948


Can a private method of a superclass be declared within a subclass?

1038


What is java util collection?

1086


How will you get the platform dependent values like line separator, path separator, etc., ?

1027


What is the difference between final, finally and finalize()?

1152


How to use string tokenizer class.

1207


Is there any case when finally will not be executed?

950


How does split work in java?

1050


Can an interface extend another interface?

1055