Question: Is it possible to create an instance of an interface in Java?

Somewhere I have read that using inner anonymous class we can do it as shown below:

```java
interface Test {
    public void wish();
}

class Main {
    public static void main(String[] args) {
        Test t = new Test() {
            public void wish() {
                System.out.println("output: hello how r u");
            }
        };
        t.wish();
    }
}

```

```none
cmd> javac Main.java
cmd> java Main
output: hello how r u

```

Is it correct here?

Answer: 
Normaly, you can create a reference for an interface. But you cant create an instance for interface.
Short answer...yes. You can use an anonymous class when you initialize a variable.
Take a look at this question: [Anonymous vs named inner classes? - best practices?](https://stackoverflow.com/q/714602)