Correct Answer : Get Lastest Questions and Answer : Explanation: Not B Not C: Pet is abstact, cannot be instantiated. Not F: incompatible type. Required Beagle, found Dog.
Question : Given the following classes:
public class ColorTest { public static void main(String[] args) { String[] colors = { "red", "blue", "green", "yellow", "maroon", "cyan" }; int count = 0; for (String c : colors) { if (count >= 4) { break; } else { continue; } if (c.length() >= 4) { colors[count] = c.substring(0, 3); } count++; } System.out.println(colors[count]); } }
Explanation: The line, if (c.length() >= 4) {, is never reached. This causes a compilation error. Note: The continue statement skips the current iteration of a for, while , or do-while loop. An unlabeled break statement terminates the innermost switch, for, while, or dowhile statement, but a labeled break terminates an outer statement.
Question : Which two actions will improve the encapsulation of a class? A. Changing the access modifier of a field from public to private B. Removing the public modifier from a class declaration C. Changing the return type of a method to void D. Returning a copy of the contents of an array or ArrayList instead of a direct reference
Question : What is the result?` 1. 97 98 99 100 null null null 2. 97 98 99 100 101 102 103 3. Compilation Fails. 4. A NullPointerException is thrown at runtime. 5. An ArraylndexoutofBoundsException is thrown at runtime.