exam questions

Exam 1z0-809 All Questions

View all questions & answers for the 1z0-809 exam

Exam 1z0-809 topic 1 question 17 discussion

Actual exam question from Oracle's 1z0-809
Question #: 16
Topic #: 2
[All 1z0-809 Questions]

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 type 1 = new Test (); //line n1
type.set("Java");
type1.set(100); //line n2
System.out.print(type.get() + " " + type1.get());
}
}
What is the result?

  • A. Java 100 >java.lang.Integer@<hashcode> B. line n1 with:
  • C. A compilation error occurs. To rectify it, replace Test<Integer> type1 = new Test<>(); line n2 with:
  • D. A compilation error occurs. To rectify it, replace type1.set (Integer(100));
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
adnano1234
Highly Voted 4 years, 6 months ago
It prints "Java 100". Tested
upvoted 9 times
...
Destroyer
Highly Voted 4 years, 7 months ago
It should print "Java 100"
upvoted 5 times
...
iSnover
Most Recent 5 months, 3 weeks ago
Selected Answer: A
A -> prints "Java 100"
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago