V
Q. What will be the output of the following Java program? public class BoxDemo { public static <U> void addBox(U u, java.util.List<Box<U>> boxes) { Box<U> box = new Box<>(); box.set(u); boxes.add(box); } public static <U> void outputBoxes(java.util.List<Box<U>> boxes) { int counter = 0; for (Box<U> box: boxes) { U boxContents = box.get(); System.out.println("[" + boxContents.toString() + "]"); counter++; } } public static void main(String[] args) { java.util.ArrayList<Box<Integer>> listOfIntegerBoxes = new java.util.ArrayList<>(); BoxDemo.<Integer>addBox(Integer.valueOf(0), listOfIntegerBoxes); BoxDemo.outputBoxes(listOfIntegerBoxes); } }
No solution found for this question.
Add Solution and get +2 points.
You must be Logged in to update hint/solution
Be the first to start discuss.
Q. If you import a package, subpackages will not be imported.
Q. Which http method send by browser that asks the server to get the page only?
Q. Which of these keywords can be used to prevent inheritance of a class?
Q. Which will legally declare,construct, and initlaize an array?
Q. which of the following can be operands of arithmetic operators?
Q. A class having an abstract method is to be declared as _______.
Discusssion
Login to discuss.