ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
Can you declare a static variable in a method?
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Can you declare a static variable in a method?
Answer
# 1
ya.
 
Is This Answer Correct ?    2 Yes 3 No
Aditya Mohata
 
  Re: Can you declare a static variable in a method?
Answer
# 2
No, you can declare static variable only in static method
 
Is This Answer Correct ?    2 Yes 2 No
Muthusenthil
 
 
 
  Re: Can you declare a static variable in a method?
Answer
# 3
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 ?    3 Yes 0 No
Murali
 
  Re: Can you declare a static variable in a method?
Answer
# 4
No static variable cannot be declared within static/non-
static method.

only "final" and "default" allowed within in method for 
variable declaration. i.e u cant use 
private,protected,public,static within method .it display 
the compile time error "Illegal modifier".
 
Is This Answer Correct ?    0 Yes 1 No
Vijayakumar Chinnasamy
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
Difference between Superclass and Subclass?  2
is there any function in java to make the text to blink?  5
what is ennumaration? AMDOC1
In what circumstances, compiler will supply a default constructor for a class?  4
Hi Friends, can you explain instance in java. In general instance means "occurence of something" . In java what is instance.  2
How will you override default serialization mechanism in java  1
What do you mean by Remote procedure call?  2
hi to all. well can you please tell me that why String class is immutable? Thanks in advance. Huawei3
Is java supports multiple inheritance? explain? Inforica11
Explain difference between final, finally and finalize?  2
How to eliminate duplicates from an array? Wipro3
what is bytecode ?explain in detail and watz the difference between bytecode and machine code? Lucent3
11. static class A { 12. void process() throws Exception { throw new Exception(); } 13. } 14. static class B extends A { 15. void process() { System.out.println(”B”); } 16. } 17. public static void main(String[] args) { 18. new B().process(); 19. } What is the result? 1 B 2 The code runs with no output. 3 Compilation fails because of an error in line 12. 4 Compilation fails because of an error in line 15.  1
what is business objects?  1
How Applets & Servlets will communicate with each other?  2
what is an object class?Explain its methods?  3
what is the use/perpose of having a method antive?  2
What is static binding and where it occurs?  2
What is multiple inheritance & can we implement it in java? Satyam4
what is request dispatcher and how does it work? CTS1
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com