Are these two statements the same for declaring an array nam
Are these two statements the same for declaring an array named: income to have the capacity for 20 elements. int[] weight = new int[100]; int weight[] = new int[100]; Will the following program work all the time? If the program will crash at some point, explain under what run condition the program will crash. If you run the class under DOS and attached at end of the byte code with an argument: Test. What will be displayed Under what run situation that the class will run smoothly to finish, explain in detail. class Test_main_method {public static void main (String[] z) {if (z[0].equals (\"Test\")) {String s = new String(); s = s+z[0]+\" abc go!\"; system.out.println(\"String s contains;\"+s);} else System.out.print(\"\ args-1:\" + z[0] +\"\ args-2:\" +z[1] +\"\ args-3:\" +z[2] +\"\ args-4: \"z[3]);}}
Solution
Answer:
24. Yes. both declarations are same
25. ans1: yes
ans2: If no command line arguments are provided while running the program, the program will crash
ans3: Then z[0] is \"Test\". So the if part is executed. A new string s is created. s becomes \"Test abc go!\". This string is displayed in output
ans4: if z[0] is \"Test\", then if part is executed. if z[0] is some other string , then the else part is executed. In both cases, the program will run smoothly.
![Are these two statements the same for declaring an array named: income to have the capacity for 20 elements. int[] weight = new int[100]; int weight[] = new in Are these two statements the same for declaring an array named: income to have the capacity for 20 elements. int[] weight = new int[100]; int weight[] = new in](/WebImages/16/are-these-two-statements-the-same-for-declaring-an-array-nam-1028609-1761532828-0.webp)