UGC-NET | UGC-NET CS 2017 Nov – III | Question 42

What is the output of the following JAVA program ?

filter_none

edit
close

play_arrow

link
brightness_4
code

Class Test {
    public static void main(String[] args) {
        Test obj = new Test();
        obj.start();
    }
    void start() {
        String stra = ”do”;
            String strb = method(stra);
        System.out.print(“: ”+stra + strb);
    }
    String method(String stra) {
        stra = stra + ”good”;
        System.out.print(stra);
        return“ good”;
    }
}

chevron_right


(A) dogood : dogoodgood
(B) dogood : gooddogood
(C) dogood : dodogood
(D) dogood : dogood


Answer: (D)

Explanation:

Quiz of this Question

My Personal Notes arrow_drop_up
Article Tags :

1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.