Creating object with reference to Interface
<p>A reference variable can be declared as a class type or an interface type.If the variable is declared as an interface type, it can reference any object of any class that implements the interface.</p>

<p>Based on the above statement I have made a code on understanding. As said above <strong>declared as an interface type, it can reference any object of any class that implements the interface</strong>. </p>

<p>But in my code is displaying displayName()method undefined at objParent.displayName();. </p>

<pre><code>public class OverridenClass
{   
    public static void main(String[] args) 
    {
     Pritable objParent = new Parent();
     objParent.sysout();
     objParent.displayName();    
    }
}

interface Pritable
{
    void sysout();
}

class Parent implements Pritable
{
    public void displayName() 
    {
     System.out.println("This is Parent Name");
    }

    public void sysout()
    {
        System.out.println("I am Printable Interfacein Parent Class");
    }
}
</code></pre>

<p>I am sure I have understood the wrong way.</p>

<p>Can some one explains the same.</p>

<p>Thanks for Reply.</p>
