5 years ago in Java Generics

What is the output of this program?

1. import java.util.*;
2. public class genericstack {
3. Stack stk = new Stack ();
4. public void push(E obj) {
5. stk.push(obj);
6. }
7. public E pop() {
8. E obj = stk.pop();
9. return obj;
10. }
11. }
12. class Output {
13. public static void main(String args[]) {
14. genericstack gs = new genericstack();
15. gs.push("Hello");
16. System.out.println(gs.pop());
17. }
18. }

[A] H
[B] Hello
[C] Runtime Error
[D] Compilation Error
Loading...
Next Question

Overall Stats

Attempted 135
Correct 42
Incorrect 33
Viewed 60

Answers

Guest
Guest
keerthi vallabaneni
keerthi vallabaneni - 3 months ago

keerthi vallabaneni from Nellore, India is saying Hello is correct answer

player p
player p - 5 months ago

player p from Makkah, Saudi Arabia is saying Hello is correct answer

ajaydeep singh
ajaydeep singh - 6 months ago

ajaydeep singh from Chandigarh, India is saying Hello is correct answer

Guriqbal Singh
Guriqbal Singh - 6 months ago

Guriqbal Singh from Chandigarh, India is saying Compilation Error is correct answer

Jarushan Naidoo
Jarushan Naidoo - 7 months ago

Jarushan Naidoo from Johannesburg, South Africa is saying Hello is correct answer

Related Questions

Which of these Exception handlers cannot be type parameterized?

  • [A] catch
  • [B] throw
  • [C] throws
  • [D] All of the mentioned

Why are generics used?

  • [A] Generics make code more fast.
  • [B] Generics make code more optimised and readable.
  • [C] Generics add stability to your code by making more of your bugs detectable at compile time.
  • [D] Generics add stability to your code by making more of your bugs detectable at run time.