Winter Sale Special Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: v4s65

1z0-809 Exam Dumps - Java SE 8 Programmer II

Go to page:
Question # 25

Given the definition of the Vehicle class:

Class Vehhicle {

int distance;//line n1

Vehicle (int x) {

this distance = x;

}

public void increSpeed(int time) {//line n2

int timeTravel = time;//line n3

class Car {

int value = 0;

public void speed () {

value = distance /timeTravel;

System.out.println (“Velocity with new speed”+value+”kmph”);

}

}

new Car().speed();

}

}

and this code fragment:

Vehicle v = new Vehicle (100);

v.increSpeed(60);

What is the result?

A.

Velocity with new speed

B.

A compilation error occurs at line n1.

C.

A compilation error occurs at line n2.

D.

A compilation error occurs at line n3.

Full Access
Question # 26

Given:

class Vehicle {

int vno;

String name;

public Vehicle (int vno, String name) {

this.vno = vno,;

this.name = name;

}

public String toString () {

return vno + “:” + name;

}

}

and this code fragment:

Set vehicles = new TreeSet <> ();

vehicles.add(new Vehicle (10123, “Ford”));

vehicles.add(new Vehicle (10124, “BMW”));

System.out.println(vehicles);

What is the result?

A.

10123 Ford10124 BMW

B.

10124 BMW10123 Ford

C.

A compilation error occurs.

D.

A ClassCastException is thrown at run time.

Full Access
Question # 27

Given the code fragment:

What is the result?

A.

A compilation error occurs.

B.

[Java, J2EE, J2ME, JSTL, JSP]

C.

null

D.

[Java, J2EE, J2ME, JSTL]

Full Access
Question # 28

Given:

public final class IceCream {

public void prepare() {}

}

public class Cake {

public final void bake(int min, int temp) {}

public void mix() {}

}

public class Shop {

private Cake c = new Cake ();

private final double discount = 0.25;

public void makeReady () { c.bake(10, 120); }

}

public class Bread extends Cake {

public void bake(int minutes, int temperature) {}

public void addToppings() {}

}

Which statement is true?

A.

A compilation error occurs in IceCream.

B.

A compilation error occurs in Cake.

C.

A compilation error occurs in Shop.

D.

A compilation error occurs in Bread

E.

All classes compile successfully.

Full Access
Question # 29

Given:

public class Counter {

public static void main (String[ ] args) {

int a = 10;

int b = -1;

assert (b >=1) : “Invalid Denominator”;

int с = a / b;

System.out.println (c);

}

}

What is the result of running the code with the –da option?

A.

-10

B.

0

C.

An AssertionError is thrown.

D.

A compilation error occurs.

Full Access
Go to page: