Question
When is static variable loaded? is it at compile time or runtime? when exactly a static block is loaded in java?

Answers

Static variable are loaded when classloader brings the class to the JVM. It is not necessary that an object has to be created. Static variables will be allocated memory space when they have been loaded. The code in a static block is loaded/executed only once i.e. when the class is first initialized. A class can have any number of static blocks. Static block is not member of a class, they do not have a return statement and they cannot be called directly. Cannot contain this or super. They are primarily used to initialize static fields.   Your Comment




More Software,Java Questions..
What is the inputsplit in map reduce software?

Can variables be used in Java without initialization?

What is the difference between java bean and enterprise java bean?

What is software configuration management?

How does the java database connectivity (jdbc) work?

What are the advantages of threads in java?

What Is Java Api For Xml-based Rpc (jax-rpc)?

How can you implement fine-grained auditing?

What is IBM’s simple explanation for Big Data’s four critical features?

What is static synchronized method in JDBC API? Give an example?

What does the NULLIF function do?

What happens if a start method is not invoked and the run method is directly invoked?

Should we override finalize method

what is the difference between mysql_fetch_array and mysql_fetch_object?

How will XML affect my document links?

What is object cloning in Java?

Why to use Style Sheets?

What are Filters in MVC?

Can you explain Application layer in OSI model?

How to define new testplan attributes?



Search
Can you Answer!!
  • Q Which method is used to get a persistent instance from the datastore
  • Q Which was a renowned Jain scholar who greatly honoured by Akbar?
  • Q Can you please explain what would you do if someone in management asked you to do something unethical?
  • Q Which is the first state to present a bill on the establishment of Lokayuktha in 1970 ?
  • Q 475...
  • Q What does hsl stand for?
  • Q Why might you be successful in such a job?
  • Q Write a pseudocode that will accept a set of marks of students and display the highest marks. The pseudocode stops when the user input -1 for marks.
  • Q There are various methods of determining marketing promotional budgets. Which statements reflect the shortfalls or disadvantages in the percentage of sales forecasting method?
  • Q In COBOL programming, what is PERFORM? What is VARYING?
  • Q Execute the qsort () in c/sort() in c++ library or your own custom sort which will sort any type of data on user defined criteria.