CJCoding With Joseph
15per day
← Back to Question List

Select topics to narrow your question pool, then enable Random to jump to a random question matching your filters.

Topics:
Java Quiz #30

Generic Class Output

easyGenerics, Classes

What does this code print?

📄 Code

1class Container<T> {
2 private T item;
3 public Container(T item) { this.item = item; }
4 public T getItem() { return item; }
5}
6 
7public class Main {
8 public static void main(String[] args) {
9 Container<Integer> c = new Container<>(42);
10 System.out.println(c.getItem());
11 }
12}