Given:
What is the result?
Show answerHide answer
Correct answer: C
myStr: 7007, myNum: 9009
Java SE 8 Programmer I
Free 1z0-808 mock exam questions 21–30, each with the answer and an explanation.
20 questions · 33 minutes · free, no sign-up
Given:
What is the result?
Correct answer: C
myStr: 7007, myNum: 9009
Given:
import java.util.*;
public class Ref {
public static void main(String[] args) {
StringBuilder s1 = new StringBuilder("Hello Java!");
String s2 = s1.toString();
List<String> lst = new ArrayList<String>();
lst.add(s2);
System.out.println(s1.getClass());
System.out.println(s2.getClass());
System.out.println(lst.getClass());
}
}
What is the result?
Correct answer: C
class java.lang.StringBuilder
class java.lang.String
class java.util.ArrayList
class java.lang.StringBuilder
class java.lang.String
class java.util.ArrayList
Given the code fragment:
What is the result?
Correct answer: C
false false
Given:
public class TestField {
int x;
int y;
public void doStuff(int x, int y) {
this.x = x;
y =this.y;
}
public void display() {
System.out.print(x + " " + y + " : ");
}
public static void main(String[] args) {
TestField m1 = new TestField();
m1.x = 100;
m1.y = 200;
TestField m2 = new TestField();
m2.doStuff(m1.x, m1.y);
m1.display();
m2.display();
}
}
What is the result?
Correct answer: C
100 200 : 100 0 :
Given the following two classes:
How should you write methods in the ElectricAccount class at line n1 so that the member
variable bill is always equal to the value of the member variable kwh multiplied by the
member variable rate?
Any amount of electricity used by a customer (represented by an instance of the customer
class) must contribute to the customer's bill (represented by the member variable bill)
through the method useElectricity method. An instance of the customer class should never
be able to tamper with or decrease the value of the member variable bill.
Correct answer: B
Option B

Correct answer: B
a, e
o, o
Given the code fragment:
What is the result?
Correct answer: D
An exception is thrown at runtime.
java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: HourOfDay
Given:
What is the result?
Correct answer: A
True false
Given:
What is the result?
Correct answer: E
Compilation fails
Which two are benefits of polymorphism?
Correct answer: C, D
More dynamic code at runtime More flexible and reusable code
Full-length mocks with the same number of questions and the same time limit as the real 1z0-808 exam. Every attempt draws a new set of questions from the full bank, so you can keep going until you pass comfortably.
Get full 1z0-808 mock exam