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...

Can you declare a static variable in a method?

Answer Posted / murali

No, Static variables can be declared as a class attributes,
for example,
public classA{
static String m2="xyz"; // this is correct form
public static void main(String args[]){
static String m1="abc"; // this gives an error
(illegal modifier for parameter;;....)
}
}

Is This Answer Correct ?    25 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does java stand for?

1201


Can we override the static methods?

1084


What is the technique adopted to create an immutable class?

1186


What is an anonymous class in java?

1161


Difference between linkedlist and arraylist.

1115


What is boolean false?

1026


Why do we need data structure in java?

1120


what are different ways in which a thread can enter the waiting state? : Java thread

1011


What do negative exponents mean?

1109


What is array class in java?

1118


When wait(), notify(), notifyall() methods are called does it releases the lock or holds the acquired lock?

1058


What is the association?

1025


What are the methods available in a class?

1127


Is java 9 released?

1065


How many types of voids are there?

1022