top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

Can an inner class be built in an Interface?

+1 vote

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
              int q;

          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?

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.