What is the output of this program?
import java.util.*; public class genericstack{ Stack stk = new Stack (); public void push(E obj) { stk.push(obj); } public E pop() { E obj = stk.pop(); return obj; } } class Output { public static void main(String args[]) { genericstack gs = new genericstack (); gs.push(36); System.out.println(gs.pop()); } }
What is the output of this program?
import java.util.*; class Output { public static void addNumbers(List super Integer> list) { for (int i = 1; i <= 10; i++) { list.add(i); } } public static void main(String args[]) { Listld = Arrays.asList(); addnumbers(10.4); System.out.println("getList(2)"); } }
What is the output of this program?
import java.util.*; class Output { public static double sumOfList(List extends Number> list) { double s = 0.0; for (Number n : list) s += n.doubleValue(); return s; } public static void main(String args[]) { Listld = Arrays.asList(1.2, 2.3, 3.5); System.out.println(sumOfList(ld)); } }
What is the output of this program?
import java.util.*; public class genericstack{ Stack stk = new Stack (); public void push(E obj) { stk.push(obj); } public E pop() { E obj = stk.pop(); return obj; } } class Output { public static void main(String args[]) { genericstack gs = new genericstack (); gs.push("Hello"); System.out.print(gs.pop() + " "); genericstack gs = new genericstack (); gs.push(36); System.out.println(gs.pop()); } }
Which of the following cannot be Type parameterized?