Menu
Topics Index
...
`

Sixes More Sixes and Dhoni


If you need explanation Read this topic

If you need Answer Take test on this topic

Sixes More Sixes and Dhoni
What will be the output of the following program?
interface SixesMachine {
    void hitSixes();
}

public abstract class DhoniInTheMaking implements SixesMachine {
    public String numberOfSixes() {
        return "6 0 6 3 6 6 6 6";
    }
    private void printRunsTrail(String runsAndRuns) {
        System.out.println(runsAndRuns);
    }
}

class Dhoni extends DhoniInTheMaking {
    public static void main(String args[]) {
        DhoniInTheMaking outputClass = new Dhoni();
        outputClass.hitSixes();
    }
    public void hitSixes() {
        numberOfSixes().substring(5, 12);
        printRunsTrail(numberOfSixes().substring(3, 7));
    }
}

A. 6 0 6 3 6 6 6 6
B. 6 3
C. 6 6
D. Compilation Error or Runtime Error
Topic: Access Modifiers In Java

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.

c

Posted by Maryam Maryam    2014-05-28 12:47:37


Answer : D Compilation_Error
> we cannot declare the abstract class " DhoniInTheMaking " as PUBLIC as it will not be the file name coz it doesn't have the main() in it
> and the print() in the abstract class should be made PUBLIC

Posted by Deepak Kumar Yadav    2014-05-28 12:54:21


answer is d.. private methods can not be accessed outside of that clas

Posted by Vijay Kumar    2014-05-28 13:04:40


Ans D: Compilation Error...private methods cant be inherited..we cant cal printRunsTrail() Directly

Posted by Uday Kumar    2014-05-28 15:48:34


Congratulations Deepak Kumar Yadav. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-05-29 04:57:52


© meritcampus 2019

All Rights Reserved.

Open In App