Menu
Topics Index
...
`

Class with multiple methods


If you need explanation Read this topic

If you need Answer Take test on this topic

Class with multiple methods
What will be the output of the following program?
public class Balu {
    String song = "Maateraani Chinnadhaani";
    public static void main(String[] args) {
        Balu b = new Balu();
        b.singMelody();
        b.singItem();
        b.singFastTrack();
    }
    private void singMelody() {
        System.out.println("Singing " + song);
    }
    private void singFastTrack() {
        System.out.println("Singing " + song);
        String song = "Guvva Gorinka Thoq";
        System.out.println("Singing " + song);
    }
    private void singItem() {
        String song = "Janavule Nerajanavule";
        System.out.println("Singing " + song);
        singMelody();
        System.out.println("Singing " + song);
    }
}

A. Singing Maateraani Chinnadhaani
Singing Janavule Nerajanavule
Singing Janavule Nerajanavule
Singing Janavule Nerajanavule
Singing Maateraani Chinnadhaani
Singing Guvva Gorinka Thoq
B. Singing Maateraani Chinnadhaani
Singing Janavule Nerajanavule
Singing Maateraani Chinnadhaani
Singing Maateraani Chinnadhaani
Singing Maateraani Chinnadhaani
Singing Guvva Gorinka Thoq
C. Singing Maateraani Chinnadhaani
Singing Janavule Nerajanavule
Singing Maateraani Chinnadhaani
Singing Janavule Nerajanavule
Singing Maateraani Chinnadhaani
Singing Guvva Gorinka Thoq
D. Singing Maateraani Chinnadhaani
Singing Maateraani Chinnadhaani
Singing Maateraani Chinnadhaani
Singing Maateraani Chinnadhaani
Singing Maateraani Chinnadhaani
Singing Maateraani Chinnadhaani
E. Some other output
F. Compilation Error or Runtime Error
Topic: Java Multiple Methods In One Class

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 is answer since first song below balu is global and then the 1 in sinItem is local to that function and it is printed when it has to be

Posted by Karteek Paruchuri    2013-06-19 12:35:00


answer is c as first func call prints first line of output..second func prints next 3 lines and third prints other lines..first prefernce is given to local variables and then class variables..

Posted by Pramod Jain    2013-06-19 12:35:48


Congratulations Karteek Paruchuri. You are this dose winner. Please send us your mobile details and we will process the recharge asap.

Posted by Merit Campus    2013-06-19 17:46:30


got the rc thank you

Posted by Karteek Paruchuri    2013-06-24 08:02:03


© meritcampus 2019

All Rights Reserved.

Open In App