top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Can an inner class be built in an Interface?

+1 vote
125 views

Explain how and with code example?

posted Dec 6, 2014 by Deepan

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

1 Answer

+3 votes
 
Best answer

Yes, an inner class may be built an Interface

Code Example:

 public interface xyz
 {
        static int p=0; 
        void m();
        class c
        {
          c()
          {
              int q;
             System.out.println("inside");
          };

          public static void main(String c[])
          {
             System.out.println("inside ");
          }
        }
  }
answer Dec 8, 2014 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?

...