Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Language Fundamentals Questions
Java command-line arguments indexing: determine what prints and whether an exception occurs. public class CommandArgs { public static void main(String[] args) { String s1 = args[1]; String s2 = args[2]; String s3 = args[3]; String s4 = args[4]; // potential out-of-bounds System.out.print(" args[2] = " + s2); } } // Invocation: > java CommandArgs 1 2 3 4
Java (jagged 3D int array) — how many lines will be printed by the nested loops? public class Test { public static void main(String [] args) { int[][][] x = new int[3][][]; int i, j; x[0] = new int[4][]; x[1] = new int[2][]; x[2] = new int[5][]; for (i = 0; i < x.length; i++) { for (j = 0; j < x[i].length; j++) { x[i][j] = new int[i + j + 1]; System.out.println("size = " + x[i][j].length); } } } } Count the total println calls produced by the inner loop.
1
2