top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

When does JVM loads a class?

+2 votes
260 views
When does JVM loads a class?
posted Aug 31, 2015 by Harshita Dhaliwal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Class loading is done by ClassLoaders in Java which can be implemented to eagerly load a class as soon as another class references it or lazy load the class until a need of class initialization occurs. If Class is loaded before its actually being used it can sit inside before being initialized. I believe this may vary from JVM to JVM. While its guaranteed by JLS that a class will be loaded when there is a need of static initialization.

answer Sep 1, 2015 by Karthick.c
Similar Questions
+2 votes

I was playing around some static inner class.

    package com.tutorial; 
    public class MyUpperClass {
        private MyUpperClass () {

        }
        private static class MyStaticInnerClass{
                    private static final MyUpperClass muc = new MyUpperClass ();
        }
        public static MyUpperClass getInstance() {
            return MyStaticInnerClass.muc;
        }
    }

Now, My question is, when does MystaticInnerClass get loaded into the JVM memory?
At the time of, when MyUpperClass get loaded or getInstance() get called?

+1 vote

As JVM uses the primitive or time slicing scheduling techniques for thread scheduling. Is it possible to know our exiting JVM using which technique for thread scheduling?

...