AllExam Dumps

DUMPS, FREE DUMPS, VCP5 DUMPS| VMWARE DUMPS, VCP DUMPS, VCP4 DUMPS, VCAP DUMPS, VCDX DUMPS, CISCO DUMPS, CCNA, CCNA DUMPS, CCNP DUMPS, CCIE DUMPS, ITIL, EXIN DUMPS,


READ Free Dumps For Oracle- 1z0-804





Question ID 21449

Given:
public class Test {
Integer x; // line 2
public static void main(String[] args) {
new Test().go(5);
}
void go(Integer i) { // line 6
System.out.print(x + ++i); // line 7
}
}
What is the result?

Option A

5

Option B

6

Option C

An exception is thrown at runtime

Option D

Compilation fails due to an error on line 6

Option E

Compilation fails due to an error on line 7

Correct Answer C
Explanation Explanation: The code compile fine but java.lang.NullPointerException is thrown at runtime. x has no value. The code would run if line 2 was changed to: Integer x = 3;


Question ID 21450

Given:
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
public class MapClass {
public static void main(String[] args) {
Map <String, String> partList = new TreeMap<>();
partList.put("P002", "Large Widget");
partList.put("P001", "Widget");
partList.put("P002", "X-Large Widget");
Set<String> keys = partList.keySet();
for (String key:keys) {
System.out.println(key + " " + partList.get(key));
}
}
}

What is the result?

Option A

p001 Widget
p002 X-Large Widget

Option B

p002 Large Widget
p001 Widget

Option C

p002 X-large Widget
p001 Widget

Option D

p001 Widget
p002 Large Widget

Option E

compilation fails

Correct Answer A
Explanation Explanation: Compiles fine. Output is: P001 Widget P002 X-Large Widget Line: partList.put("P002", "X-Large Widget"); >> overwrites >> line:partList.put("P002", "Large Widget"); put V put(K key, V value) Associates the specified value with the specified key in this map (optional operation). If the map previously contained a mapping for the key, the old value is replaced by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.) Parameters: key - key with which the specified value is to be associated value - value to be associated with the specified key Returns: the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)

Send email to admin@getfreedumps for new dumps request!!!