Home » JAVA Programming » Methods » Question
  1. In the below code, which call to num() method is appropriate?

    class Result
    {

    public static int num(int ...x)
    {
    return;
    }
    static void main(String args[])
    {
    num(10);
    num(10,20);
    num(10,20,30);
    num(10,20,30,40);
    }
    }
    1. only num(10,20)
    2. only num(10)
    3. only num(10) & num(10,20)
    4. all of the mentioned
    5. None of these
Correct Option: D

sum is a variable argument method and hence it can take any number as argument.



Your comments will be displayed only after manual approval.