| Exam Code/Number: | 1Z0-853Join the discussion |
| Exam Name: | Java Standard Edition 5 Programmer Certified Professional Exam |
| Certification: | Oracle |
| Question Number: | 362 |
| Publish Date: | Nov 22, 2026 |
|
Rating
100%
|
|
Given:
11.
public abstract class Shape {
12.
private int x;
13.
private int y;
14.
public abstract void draw();
15.
public void setAnchor(int x, int y) {
16.
this.x = x;
17.
this.y = y;
18.
}
19.
}
Which two classes use the Shape class correctly? (Choose two.)
Given:
11.
public void genNumbers() {
12.
ArrayList numbers = new ArrayList();
13.
for (int i=0; i<10; i++) {
14.
int value = i * ((int) Math.random());
15.
Integer intObj = new Integer(value);
16.
numbers.add(intObj);
17.
}
18.
System.out.println(numbers);
19.
}
Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbage collection?
Given:
25.
int x = 12;
26.
while (x < 10) {
27.
x--;
28.
}
29.
System.out.print(x);
What is the result?
Given a class Repetition:
1.package utils;
2.3.
public class Repetition {
4.public static String twice(String s) { return s + s; }
5.}
and given another class Demo:
1.// insert code here
2.3.
public class Demo {
4.public static void main(String[] args) {
5.System.out.println(twice("pizza"));
6.}
7.}
Which code should be inserted at line 1 of Demo.java to compile and run Demo to print "pizzapizza"?
Click the Exhibit button.
Given:
25.
try {
26.
A a = new A();
27.
a.method1();
28.
} catch (Exception e) {
29.
System.out.print("an error occurred");
30.
}
Which two statements are true if a NullPointerException is thrown on line 3 of class C? (Choose two.)