Menu
Topics Index
...
`

Inner Classes2110


If you need explanation Read this topic

If you need Answer Take test on this topic

Inner Classes2110
What will be the output of the following program?
public class King {
    public static void main(String[] args) {
        King k = new King();
        Elephant e = new Elephant();
        System.out.print("Output = ");
        System.out.print(e.step2(2, 3));
    }
    interface Queen {

        float step2(int low, int high);
    }
    interface Pawn {

        float step3(int a, int b, int c);
    }
    abstract class Knight implements Queen, Pawn {
    }
    class Elephant implements Queen {
        public float step2(int x, int y) {
            return 2;
        }
    }
}

A. Output = 2f
B. Output = 2.0f
C. Output = 2.0
D. Some other output
E. 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 e.compilation problem. no enclosing instance of king is accessible.must qualify the allocatn with enclosing instanc of king

Posted by Maheshwari Natarajan    2014-06-06 13:08:22


Ans:C  step2() method returns  2.0

Posted by Indra Chereddy    2014-06-06 13:18:30


E.comp error as we r trying to refernce non-static variale from static content.ie; Elephant e.

Posted by Shabaaz Shaikz    2014-06-06 13:38:28


option is c it wil retrn the 2.0

Posted by Vijay Kumar    2014-06-06 13:40:56


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

Posted by Merit Campus    2014-06-09 11:43:52


© meritcampus 2019

All Rights Reserved.

Open In App