adplus-dvertising
frame-decoration

Question

What is the output of this program?
    import java.util.*;
    public class genericstack <E>
    {
        Stack <E> stk = new Stack <E>();
	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 <String> gs = new genericstack<String>();
            gs.push("Hello");
            System.out.print(gs.pop() + " ");
            genericstack <Integer> gs = new genericstack<Integer>();
            gs.push(36);
            System.out.println(gs.pop());
        }
    }

a.

Error

b.

Hello

c.

36

d.

Hello 36

Posted under Java Programming

Answer: (d).Hello 36

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?

Similar Questions

Discover Related MCQs

Q. Which of these Exception handlers cannot be type parameterized?

Q. Which of the following cannot be Type parameterized?

Q. Which statement is true about assertions in the Java programming language?

Q. Which three statements are true?

1. Assertion checking is typically enabled when a program is deployed.
2. It is never appropriate to write code to handle failure of an assert statement.
3. Assertion checking is typically enabled during program development and testing.
4. Assertion checking can be selectively enabled or disabled on a per-package basis, but not on a per-class basis.
5. Assertion checking can be selectively enabled or disabled on both a per-package basis and a per-class basis.

Q. Which statement is true?

Q. Which of the following statements is true?

Q. Which of the following statements is true?

Q. ____________method can be given parameters via using command line arguments.

Q. Number of arguments can be passed to main() is?

Q. args in an array of String.

Q. ___________ is a very small Java framework that makes it trivial to parse command line parameters.

Q. Which tab is used to pass command line argument in eclipse?

Q. Recursion in Java is a way of calling the method from within the same method. State TRUE or FALSE.

Q. Java uses ___ type of memory to implement Recursion.

Q. Java uses Stack type memory instead of Heap type memory in implementing Recursion because of ___ feature of STACK.

Q. Recursion in Java applies to ___.

Q. Uses are Recursion in Java are___.

Q. Which is better in terms of memory utilization Recursion or Loops in Java?

Q. Which is the common problem with Recursive methods in Java?

Q. Recursion usually stops when the Java Runtimeencounters an IF or ELSE statement with a RETURN statement. State TRUE or FALSE.