nerdexam
Oracle

1Z0-809 · Question #120

1Z0-809 Question #120: Real Exam Question with Answer & Explanation

Sign in or unlock 1Z0-809 to reveal the answer and full explanation for question #120. The question stem and answer options stay visible for context.

Question

Given: public class Test<T> { private T t; public T get () { return t; } public void set (T t) { this.t = t; } } public static void main (String args [ ] ) { Test<String> type = new Test<>(); Test type1 = new Test ();//line n1 type.set("Java"); type.set(100); //line n2 System.out.print(type.get() + " " + type1.get()); } What is the result?

Options

  • AJava 100
  • Bjava.lang.String@<hashcode>=java.lang.Integer@<hashcode>
  • CA compilation error occurs. To rectify it, replace line n1 with: Test<Integer> type1 = new Test<>();
  • DA compilation error occurs. To rectify it, replace line n2 with: type1.set (Integer(100));

Unlock 1Z0-809 to see the answer

You've previewed enough free 1Z0-809 questions. Unlock 1Z0-809 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Full 1Z0-809 Practice