Java | Functions | Question 2

filter_none

edit
close

play_arrow

link
brightness_4
code

public class Main { 
    public static void main(String args[]) { 
       String x = null; 
       giveMeAString(x); 
       System.out.println(x); 
    
    static void giveMeAString(String y) 
    
       y = "GeeksQuiz"
    
}

chevron_right


(A) GeeksQuiz
(B) null
(C) Compiler Error
(D) Exception


Answer: (B)

Explanation: Parameters in Java is passed by value. So the changes made to y do not reflect in main().

Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :
Practice Tags :


1


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