top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Java: which class 1st loaded into memory Base class or Derived class?

+2 votes
289 views

If we extends the one class then which class 1st loaded into memory Base class or Derived class?

posted Sep 25, 2014 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

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
using System;

namespace CareerRideTest
{    
  class A
  {    
    public A()
    {
      Console.WriteLine("I am in A");
    }
  }

  class B : A
  {
    public B()
    {
      Console.WriteLine("I am in B");
    }
  }

  class C : B
  {
    static C()
    {
      Console.WriteLine("I am in Static C");
    }
    public C()
    {
      Console.WriteLine("I am in C");
    }
  }    

  class MainClass
  {
    static void Main(string[] args)
    {
      C obj = new C();    
      Console.ReadKey();    
    }
  }    
}
+1 vote

How object class is inherited into all the Java class without having extends Keyword. I mean what is the logic for making a class to inherit to all the other classes.

...