MultipleChoice
Given the code fragment:
List<String> codes = Arrays.asList (''DOC'', ''MPEG'', ''JPEG'');
codes.forEach (c -> System.out.print(c + '' ''));
String fmt = codes.stream()
.filter (s-> s.contains (''PEG''))
.reduce((s, t) -> s + t).get();
System.out.println(''\n'' + fmt);
What is the result?
OptionsMultipleChoice
Given the code fragment:
public class Foo {
public static void main (String [ ] args) {
Map<Integer, String> unsortMap = new HashMap< > ( );
unsortMap.put (10, ''z'');
unsortMap.put (5, ''b'');
unsortMap.put (1, ''d'');
unsortMap.put (7, ''e'');
unsortMap.put (50, ''j'');
Map<Integer, String> treeMap = new TreeMap <Integer, String> (new
Comparator<Integer> ( ) {
@Override public int compare (Integer o1, Integer o2) {return o2.compareTo
(o1); } } );
treeMap.putAll (unsortMap);
for (Map.Entry<Integer, String> entry : treeMap.entrySet () ) {
System.out.print (entry.getValue () + '' '');
}
}
}
What is the result?
OptionsMultipleChoice
Given the code fragment:
UnaryOperator
List
loanValues.stream()
.filter(lv -> lv >= 1500)
.map(lv -> uo1.apply(lv))
.forEach(s -> System.out.print(s + '' ''));
What is the result?
OptionsMultipleChoice
Given:
class CheckClass {
public static int checkValue (String s1, String s2) {
return s1 length() -- s2.length();
}
}
and the code fragment:
String[] strArray = new String [] {''Tiger'', ''Rat'', ''Cat'', ''Lion''}
//line n1
for (String s : strArray) {
System.out.print (s + '' '');
}
Which code fragment should be inserted at line n1 to enable the code to print Rat Cat Lion Tiger?
OptionsMultipleChoice
Given that /green.txt and /colors/yellow.txt are accessible, and the code fragment:
Path source = Paths.get(''/green.txt);
Path target = Paths.get(''/colors/yellow.txt);
Files.move(source, target, StandardCopyOption.ATOMIC_MOVE);
Files.delete(source);
Which statement is true?
OptionsMultipleChoice
Given:
Book.java:
public class Book {
private String read(String bname) { return ''Read'' + bname }
}
EBook.java:
public class EBook extends Book {
public class String read (String url) { return ''View'' + url }
}
Test.java:
public class Test {
public static void main (String[] args) {
Book b1 = new Book();
b1.read(''Java Programing'');
Book b2 = new EBook();
b2.read(''http://ebook.com/ebook'');
}
}
What is the result?
OptionsMultipleChoice
Given the code fragment:
ZonedDateTime depart = ZonedDateTime.of(2015, 1, 15, 3, 0, 0, 0, ZoneID.of(''UTC-7''));
ZonedDateTime arrive = ZonedDateTime.of(2015, 1, 15, 9, 0, 0, 0, ZoneID.of(''UTC-5''));
long hrs = ChronoUnit.HOURS.between(depart, arrive); //line n1
System.out.println(''Travel time is'' + hrs + ''hours'');
What is the result?
OptionsMultipleChoice
Given the code fragment:
List
Predicate
System.out.println(''Searching...'');
return n.contains(''red'');
};
colors.stream()
.filter(c -> c.length() > 3)
.allMatch(test);
What is the result?
OptionsMultipleChoice
Given:
class UserException extends Exception { }
class AgeOutOfLimitException extends UserException { }
and the code fragment:
class App {
public void doRegister(String name, int age)
throws UserException, AgeOutOfLimitException {
if (name.length () < 6) {
throw new UserException ();
} else if (age >= 60) {
throw new AgeOutOfLimitException ();
} else {
System.out.println(''User is registered.'');
}
}
public static void main(String[ ] args) throws UserException {
App t = new App ();
t.doRegister(''Mathew'', 60);
}
}
What is the result?
OptionsMultipleChoice
Given the content:
and given the code fragment:
Which two code fragments, when inserted at line 1 independently, enable the code to print ''Wie geht's?''
Options