Simulation of 1Z0-852 simulations materials and item pool for Oracle certification for customers, Real Success Guaranteed with Updated 1Z0-852 pdf dumps vce Materials. 100% PASS Java Standard Edition 6 Programmer Certified Professional Upgrade Exam exam Today!
2021 Aug 1Z0-852 practice
Q11. Given:
11.
public class PingPong implements Runnable {
12.
synchronized void hit(long n) {
13.
for(int i = 1; i < 3; i++)
14.
System.out.print(n + "-" + i + " ");
15.
}
16.
public static void main(String[] args) {
17.
new Thread(new PingPong()).start();
18.
new Thread(new PingPong()).start();
19.
}
20.
public void run() {
21.
hit(Thread.currentThread().getId());
22.
}
23.
}
Which two statements are true? (Choose two.)
A. The output could be 8-1 7-2 8-2 7-1
B. The output could be 7-1 7-2 8-1 6-1
C. The output could be 8-1 7-1 7-2 8-2
D. The output could be 8-1 8-2 7-1 7-2
Answer: C,D
Explanation:
Q12. Given:
3.
import java.util.*;
4.
public class G1 {
5.
public void takeList(List<? extends String> list) {
6.
// insert code here
7.
}
8.
}
Which three code fragments, inserted independently at line 6, will compile? (Choose three.)
A. list.add("foo");
B. Object o = list;
C. String s = list.get(0);
D. list = new ArrayList<String>();
E. list = new ArrayList<Object>();
Answer: B,C,D
Explanation:
Q13. Given:
10.
interface Foo {}
11.
class Alpha implements Foo {}
12.
class Beta extends Alpha {}
13.
class Delta extends Beta {
14.
public static void main( String[] args ) {
15.
Beta x = new Beta();
16.
// insert code here
17.
}
18.
}
Which code, inserted at line 16, will cause a java.lang.ClassCastException?
A. Alpha a = x;
B. Foo f = (Delta)x;
C. Foo f = (Alpha)x;
D. Beta b = (Beta)(Alpha)x;
Answer: B
Explanation:
Q14. RAG DROP
Click the Task button.
Answer:
Q15. Given:
11.
abstract class Vehicle { public int speed() { return 0; }
12.
class Car extends Vehicle { public int speed() { return 60; }
13.
class RaceCar extends Car { public int speed() { return 150; } ...
21.
RaceCar racer = new RaceCar();
22.
Car car = new RaceCar();
23.
Vehicle vehicle = new RaceCar();
24.
System.out.println(racer.speed() + ", " + car.speed()
25.
+ ", " + vehicle.speed());
What is the result?
A. 0, 0, 0
B. 150, 60, 0
C. Compilation fails.
D. 150, 150, 150
E. An exception is thrown at runtime.
Answer: D
Explanation:

Regenerate 1Z0-852 free draindumps:
Q16. Given:
11.
// insert code here
12.
private N min, max;
13.
public N getMin() { return min; }
14.
public N getMax() { return max; }
15.
public void add(N added) {
16.
if (min == null || added.doubleValue() < min.doubleValue())
17.
min = added;
18.
if (max == null || added.doubleValue() > max.doubleValue())
19.
max = added;
20.
}
21.
}
Which two, inserted at line 11, will allow the code to compile? (Choose two.)
A. public class MinMax<?> {
B. public class MinMax<? extends Number>
{
C. public class MinMax<N extends Object>
{
D. public class MinMax<N extends Number>
{
E. public class MinMax<? extends Object> {
F.
public class MinMax<N extends Integer> {
Answer: D,F
Explanation:
Q17. Given:
1.
public class Plant {
2.
private String name;
3.
public Plant(String name) { this.name = name; }
4.
public String getName() { return name; }
5.
}
1.
public class Tree extends Plant {
2.
public void growFruit() { }
3.
public void dropLeaves() { }
4.
}
Which statement is true?
A. The code will compile without changes.
B. The code will compile if public Tree() { Plant(); } is added to the Tree class.
C. The code will compile if public Plant() { Tree(); } is added to the Plant class.
D. The code will compile if public Plant() { this("fern"); } is added to the Plant class.
E. The code will compile if public Plant() { Plant("fern"); } is added to the Plant class.
Answer: D
Explanation:
Q18. Given:
11.
public static void main(String[] args) {
12.
Object obj = new int[] { 1, 2, 3 };
13.
int[] someArray = (int[])obj;
14.
for (int i : someArray) System.out.print(i + " ");
15.
}
What is the result?
A. 1 2 3
B. Compilation fails because of an error in line 12.
C. Compilation fails because of an error in line 13.
D. Compilation fails because of an error in line 14.
E. A ClassCastException is thrown at runtime.
Answer: A
Explanation:
Q19. Given:
1.
public class BuildStuff {
2.
public static void main(String[] args) {
3.
Boolean test = new Boolean(true);
4.
Integer x = 343;
5.
Integer y = new BuildStuff().go(test, x);
6.
System.out.println(y);
7.
}
8.
int go(Boolean b, int i) {
9.
if(b) return (i/7);
10.
return (i/49);
11.
}
12.
}
What is the result?
A. 7
B. 49
C. 343
D. Compilation fails.
E. An exception is thrown at runtime.
Answer: B
Explanation:
Q20. Which two scenarios are NOT safe to replace a StringBuffer object with a StringBuilder object?(Choose two.)
A. When using versions of Java technology earlier than 5.0.
B. When sharing a StringBuffer among multiple threads.
C. When using the java.io class StringBufferInputStream.
D. When you plan to reuse the StringBuffer to build more than one string.
Answer: A,B
Explanation:
83. Given:
1.
public class LineUp {
2.
public static void main(String[] args) {
3.
double d = 12.345;
4.
// insert code here
5.
}
6.
}
Which code fragment, inserted at line 4, produces the output | 12.345|?
A. System.out.printf("|%7d| n", d);
B. System.out.printf("|%7f| n", d);
C. System.out.printf("|%3.7d| n", d);
D. System.out.printf("|%3.7f| n", d);
E. System.out.printf("|%7.3d| n", d);
F. System.out.printf("|%7.3f| n", d);
Answer: F
Explanation: