nerdexam
Oracle

1Z0-851 · Question #3

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 ||…

The correct answer is D. public class MinMax<N extends Number> { F. public class MinMax<N extends Integer> {. See the full explanation below for the reasoning.

Question

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.)

Options

  • Apublic class MinMax<?> {
  • Bpublic class MinMax<? extends Number> {
  • Cpublic class MinMax<N extends Object> {
  • Dpublic class MinMax<N extends Number> {
  • Epublic class MinMax<? extends Object> {
  • Fpublic class MinMax<N extends Integer> {

How the community answered

(65 responses)
  • A
    2% (1)
  • B
    5% (3)
  • C
    12% (8)
  • D
    78% (51)
  • E
    3% (2)

Community Discussion

No community discussion yet for this question.

Full 1Z0-851 Practice