What is the result?

Given: What is the result? A. There is no output B. d is output C. A StringIndexOutOfBoundsException is thrown at runtime D. An ArrayIndexOutOfBoundsException is thrown at runtime E. A NullPointException is thrown at runtime F. A StringArrayIndexOutOfBoundsException is thrown at runtime Explanation: There are only 11 characters in the string “Hello World”. The code […]

Read More

What changes will make this code compile?

Given a java source file: What changes will make this code compile? (Select Two) A. Adding the public modifier to the declaration of class x B. Adding the protected modifier to the x() constructor C. Changing the private modifier on the declaration of the one() method to protected D. Removing the Y () constructor E. […]

Read More

What is the result?

Given: What is the result? A. They match They really match B. They really match C. They match D. Nothing Prints E. They really match They really match Explanation: The strings are not the same objects so the == comparison fails. See note #1 below. As the value of the strings are the same equals […]

Read More

Which two are valid declarations of a two-dimensional array?

Which two are valid declarations of a two-dimensional array? A. int [] [] array2D; B. int [2] [2] array2D; C. int array2D []; D. int [] array2D []; E. int [] [] array2D []; Explanation:int[][] array2D; is the standard convention to declare a 2-dimensional integer array. int[] array2D[]; works as well, but it is not […]

Read More

What is the result?

Given the code fragment: System.out.printIn ("Result: " +3+5);System.out.printIn ("Result: " + (3+5)); What is the result? A. Result: 8 Result: 8 B. Result: 35 Result: 8 C. Result: 8 Result: 35 D. Result: 35 Result: 35 Explanation:In the first statement 3 and 5 are treated as strings and are simply concatenated.In the first statement 3 […]

Read More

Which two are possible outputs?

Given: Which two are possible outputs? A. Option A B. Option B C. Option C D. Option D Explanation: The first println statement, System.out.println(“Before if clause”);, will always run. If Math.Random() > 0.5 then there is an exception. The exception message is displayed and the program terminates. If Math.Random() > 0.5 is false, then the […]

Read More