Search Interview Questions | ![]() ![]() Click here and help us by providing the answer. ![]() Click Correct / Improve and please let us know. |
|
| ||||
Interview Questions and Answers | ||||
| ||||
Ans. 1st is a valid and standard declaration. 2nd results in compilation error as only 2 dots are there. 3rd results in compilation error as three dots are not consecutive and broken. 4 through 6 may not be standard and ideal way of declarations but they are valid and will compile and work fine. 7 is valid declaration. 8 and 9 will result in compilation error as var args can only be provided to last argument. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
![]() | ||||
![]() private static void method(String[] arg) and private static void method(String... arg) | ||||
![]() void method(int... x){}; void method(int[] x){}; | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() or What is the use of var args ? | ||||
![]() void method(int... x, int y){}; void method(int... x,int... y){}; | ||||
![]() void method(int x ){}; void method(int... x){}; | ||||
![]() public class BuggyBread { public static void main(String[] args) { method("Hello","World"); } private static void method(String... args){ for(String arg:args){ System.out.println(arg); } } } | ||||