Menu
Topics Index
...
`

Sixes More Sixes and Dhoni2837


If you need explanation Read this topic

If you need Answer Take test on this topic

Sixes More Sixes and Dhoni2837
What will be the output of the following program?
interface SixesMachine {
    void hitSixes();
}
abstract class DhoniInTheMaking implements SixesMachine {
    public String numberOfSixes() {
        return "6 0 6 3 6 6 6 6";
    }
    public void printRunsTrail(String runsAndRuns) {
        System.out.println(runsAndRuns);
    }
}
public class Dhoni extends DhoniInTheMaking {
    public static void main(String args[]) {
        DhoniInTheMaking outputClass = new Dhoni();
        outputClass.hitSixes();
    }
    public void hitSixes() {
        numberOfSixes();
        printRunsTrail(numberOfSixes());
    }
}

A. 6 0 6 3 6 6 6 6
6 0 6 3 6 6 6 6
B. 6 0 6 3 6 6 6 6
C. Compilation Error
D. Runtime Error
Topic: Difference Between Interfaces And Abstract Classes

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 B.
for the first call of numberOfSixes() we are not printing the  data. for the second call we are printing the data. so it will print the runs for one time.

Posted by Gopinath Manchikanti    2014-08-21 08:38:01


b.in first time call of the functn numofsix()..data is not prntd...in secnd call data is prntd..so it wil prnt the run for one time only

Posted by Asma Mujtaba Khan    2014-08-21 10:55:37


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

Posted by Merit Campus    2014-08-22 05:15:03


© meritcampus 2019

All Rights Reserved.

Open In App