Menu
Topics Index
...
`

Creating Interface


If you need explanation Read this topic

If you need Answer Take test on this topic

Creating Interface
What will be the output of the following program?
interface Pet
{
    public void test();
}
class Animal implements Pet
{
    public void test()
    {
        System.out.println("Interface Method Implemented");
        System.out.println("rest of the code");
    }
    public static void main(String args[])
    {
        Pet p = new Animal();
        p.test();
    }
}

A. Interface Method Implemented
B. Interface Method Implemented
Interface Method Implemented
C. Interface Method Implemented
rest of the code
D. Compilation Error or Runtime Error
Topic: Future Task Java Program Using Interfaces

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Ans is C...object is created for Animal and test method is called and the corresponding two lines gets prunted

Posted by Badam Swathi    2014-08-04 09:07:35


And d......
construtor are not defined properly

Posted by Atul Gawai    2014-08-04 09:43:49


ans is c

Posted by Shubham Bansal    2014-08-04 10:10:58


c only the default constructor is alloted by the jvm interface is having refrence only for class only the memory is created.

Posted by Din Kurth    2014-08-04 17:06:37


Congratulations Badam Swathi. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-08-05 04:47:45


© meritcampus 2019

All Rights Reserved.

Open In App