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                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
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
what is a static block?
 Question Submitted By :: Sumalatha
I also faced this Question!!     Rank Answer Posted By  
 
  Re: what is a static block?
Answer
# 1
A static block or a static initializer is a block that
appears within a class definition but outside any member
definition with the keyword static ahead of it. Example:


class MyClass {
    private static double myValue;
    static {
        myValue = Double.parseDouble( System.getProperty(
"version" ) );
    }
}

It is mainly used to perform static construction i.e.
initialization of static variables (see above example). The
static initializer is executed when the class is loaded by
the JVM.
 
Is This Answer Correct ?    0 Yes 0 No
Ranganathkini
 
  Re: what is a static block?
Answer
# 2
static block contains  a code which is executed without 
object of  a class.i.e is excuted at the time of class 
loading
 
Is This Answer Correct ?    1 Yes 0 No
Madan
 
 
 
  Re: what is a static block?
Answer
# 3
static block is used to initialization during the JVM start 
up
 
Is This Answer Correct ?    0 Yes 0 No
Ravikiran
 
  Re: what is a static block?
Answer
# 4
Static block is executed when the class is loaded into the 
memory before the main(). Only once it will be executed.
 
Is This Answer Correct ?    0 Yes 0 No
Srinivasa
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
Difference between a Scrollbar and a ScrollPane?  1
How will you create the class for the following scenario? Employees under one employee? Bally-Technologies2
What are field variable and local variable?  2
What is the range of the char type?  2
What is a super class and how super class be called?  3
what is real-time example of runtime polymorphism and compile time polymorphism  1
After compilation of java program we'll get .class code. If it's generated in OS Windows XP will it work on OS Linux? If yes why? If no why? Aricent4
Can we declare an anonymous class as both extending a class and implementing an interface? Wipro7
what is the difference between sleep() and Wait()? Accenture4
can we declare private class in java file?  6
What is the life cycle of an Applet ?  1
What Method and class used for Connection pooling ? Wipro4
What is static variable and static method? TCS8
10. class Nav{ 11. public enum Direction { NORTH, SOUTH, EAST, WEST } 12. } 13. public class Sprite{ 14. // insert code here 15. } Which code, inserted at line 14, allows the Sprite class to compile? a)Direction d = NORTH; b)Nav.Direction d = NORTH; c)Direction d = Direction.NORTH; d)Nav.Direction d = Nav.Direction.NORTH;  1
how can u create the object with out new operator  2
What is the difference between jsp and servlet? Symphony5
Which all r Final classes in java except string?  3
What is the differnence between String Buffer and String builder despite having knowledge that String builder is faster than String Buffer and last one is threadsafe.please tell another important difference.  3
what is overloading in java? DNS4
Explain Global variables in Packages?  2
 
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