Online Access Free 1Z0-853 Exam Questions
Exam Code: | 1Z0-853 |
Exam Name: | Java Standard Edition 5 Programmer Certified Professional Exam |
Certification Provider: | Oracle |
Free Question Number: | 362 |
Posted: | Sep 08, 2025 |
Given:
1.class Pizza {
2.java.util.ArrayList toppings;
3.public final void addTopping(String topping) {
4.toppings.add(topping);
5.}
6.}
7.public class PepperoniPizza extends Pizza {
8.public void addTopping(String topping) {
9.System.out.println("Cannot add Toppings");
10.
}
11.
public static void main(String[] args) {
12.
Pizza pizza = new PepperoniPizza();
13.
pizza.addTopping("Mushrooms");
14.
}
15.
}
What is the result?
Given:
1.public class Drink implements Comparable {
2.public String name;
3.public int compareTo(Object o) {
4.return 0;
5.}
6.}
and:
20.
Drink one = new Drink();
21.
Drink two = new Drink();
22.
one.name= "Coffee";
23.
two.name= "Tea";
23.
TreeSet set = new TreeSet();
24.
set.add(one);
25.
set.add(two);
A programmer iterates over the TreeSet and prints the name of each Drink object.
What is the result?
Given:
1.public class TestOne {
2.public static void main (String[] args) throws Exception {
3.Thread.sleep(3000);
4.System.out.println("sleep");
5.}
6.}
What is the result?