A method is declared to take three arguments. A program calls this method and passes only two arguments.
What is the result?
A.
Compilation fails.
B.
The third argument is given the value null.
C.
The third argument is given the value void.
D.
The third argument is given the value zero.
E.
The third argument is given the appropriate false value for its declared type.
F.
An exception occurs when the method attempts to access the third argument.
Explanation:
The problem is noticed at build/compile time. At build you would receive an error message like:
required: int,int,int
found: int,int
“A”
Build/Compile time time Error.
The Answer is A.
Upon compilation, the java compiler will return an error with the message that “the actual and formal argument lists differ in length”.
I agree with A.
But real answer is “IT DEPENDS ON THE TYPE OF ARGUMENTS”.
This compiles:
class VarArgClass {
public static void main(String args[]) {
new VarArgClass().varArgProc(1,2);
}
public void varArgProc(int i, int j, String… strs) {
}
}
Three arguments method, two argument call.
Haha, you can pass an empty array…, but with an array argument as last argument you can pass more than three arguments.