Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Java | Functions | Question 6

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Predict the output?




class Main {
    public static void main(String args[]) {   
             System.out.println(fun());
    }   
    static int fun(int x = 0)
    {
      return x;
    }
}

(A) 0
(B) Garbage Value
(C) Compiler Error
(D) Runtime Error


Answer: (C)

Explanation: Java doesn’t support default arguments. In Java, we must write two different functions.

Quiz of this Question

My Personal Notes arrow_drop_up
Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads