Oracle Certified Professional Java Se 8 Programmer · Free Practice Question Easy
Question 41
Given code:
- package com.udayan.ocp;
- class Printer<T implements Cloneable> {}
- public class Test {
- public static void main(String[] args) {
- Printer<String> printer = new Printer<>();
- System.out.println(printer);
- }
- }
What is the result?
- A Some text containing @ symbol
- B Compilation error for Test class
- C Compilation error for Printer class
Reveal correct answer
Correct answer: C
Explanation
For bounds, extends keyword is used for both class and interface.
Correct declaration of Printer class should be:
class Printer<T extends Cloneable> {}
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
You must be logged in to post a comment.
