Weekend Sale - Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: sntaclus

Given:

Which option fails?

A.

Foo mark = new Foo (“Steve”, 100);

B.

Foo pair = Foo.twice (“Hello World!”);

C.

Foo percentage = new Foo(“Steve”, 100);

D.

Foo grade = new Foo <> (“John”, “A”);

Given:

public class Test {

private T t;

public T get () {

return t;

}

public void set (T t) {

this.t = t;

}

public static void main (String args [ ] ) {

Test type = new Test<>();

Test type 1 = new Test ();//line n1

type.set(“Java”);

type1.set(100);//line n2

System.out.print(type.get() + “ “ + type1.get());

}

}

What is the result?

A.

Java 100

B.

java.lang.string@java.lang.Integer@

C.

A compilation error occurs. To rectify it, replace line n1 with:Test type1 = new Test<>();

D.

A compilation error occurs. To rectify it, replace line n2 with:type1.set (Integer(100));

Given the code fragments:

4. void doStuff() throws ArithmeticException, NumberFormatException, Exception {

5. if (Math.random() >-1 throw new Exception (“Try again”);

6. }

and

24. try {

25. doStuff ( ):

26. } catch (ArithmeticException | NumberFormatException | Exception e) {

27. System.out.println (e.getMessage()); }

28. catch (Exception e) {

29. System.out.println (e.getMessage()); }

30. }

Which modification enables the code to print Try again?

A.

Comment the lines 28, 29 and 30.

B.

Replace line 26 with:} catch (Exception | ArithmeticException | NumberFormatException e) {

C.

Replace line 26 with:} catch (ArithmeticException | NumberFormatException e) {

D.

Replace line 27 with:throw e;

Given the code fragment:

List empDetails = Arrays.asList(“100, Robin, HR”,

“200, Mary, AdminServices”,

“101, Peter, HR”);

empDetails.stream()

.filter(s-> s.contains(“1”))

.sorted()

.forEach(System.out::println); //line n1

What is the result?

A.

100, Robin, HR101, Peter, HR

B.

E. A compilation error occurs at line n1.

C.

100, Robin, HR101, Peter, HR200, Mary, AdminServices

D.

100, Robin, HR200, Mary, AdminServices101, Peter, HR

What is the result?

A.

A compilation error occurs at line 7.

B.

100

C.

A compilation error occurs at line 8.

D.

A compilation error occurs at line 15.

Given:

class RateOfInterest {

public static void main (String[] args) {

int rateOfInterest = 0;

String accountType = “LOAN”;

switch (accountType) {

case “RD”;

rateOfInterest = 5;

break;

case “FD”;

rateOfInterest = 10;

break;

default:

assert false: “No interest for this account”; //line n1

}

System.out.println (“Rate of interest:” + rateOfInterest);

}

}

and the command:

java –ea RateOfInterest

What is the result?

A.

Rate of interest: 0

B.

An AssertionError is thrown.

C.

No interest for this account

D.

A compilation error occurs at line n1.

Given the code fragment:

What is the result?

A.

4000 : 2000

B.

4000 : 1000

C.

1000 : 4000

D.

1000 : 2000

Given the definition of the Emp class:

public class Emp

private String eName;

private Integer eAge;

Emp(String eN, Integer eA) {

this.eName = eN;

this.eAge = eA;

}

public Integer getEAge () {return eAge;}

public String getEName () {return eName;}

}

and code fragment:

Listli = Arrays.asList(new Emp(“Sam”, 20), New Emp(“John”, 60), New Emp(“Jim”, 51));

Predicate agVal = s -> s.getEAge() > 50;//line n1

li = li.stream().filter(agVal).collect(Collectors.toList());

Stream names = li.stream()map.(Emp::getEName);//line n2

names.forEach(n -> System.out.print(n + “ “));

What is the result?

A.

Sam John Jim

B.

John Jim

C.

A compilation error occurs at line n1.

D.

A compilation error occurs at line n2.