Question
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
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 types cannot be used to initiate a generic type?
View solution
Q. Which of these instance cannot be created?
View solution
Q. Which of these data type cannot be type parameterized?
View solution
Q. Which of these is wildcard symbol?
View solution
Q. What is use of wildcards?
View solution
Q. Which of these keywords is used to upper bound a wildcard?
View solution
Q. Which of these is an correct way making a list that is upper bounded by class Number?
View solution
Q. Which of the following keywords are used for lower bounding a wild card?
View solution
Q. Which of the following is not an Enterprise Beans type?
View solution
Q. Which of the following is not true about Java beans?
View solution
Q. Which file separator should be used by MANIFEST file?
View solution
Q. Which of the following is correct error when loading JAR file with duplicate name?
View solution
Q. Java Beans are extremely secured?
View solution
Q. Which of the following is not a feature of Beans?
View solution
Q. What is the attribute of java bean to specify scope of bean to have single instance per Spring IOC?
View solution
Q. Which attribute is used to specify initialization method?
View solution
Q. Which attribute is used to specify destroy method?
View solution
Q. How to specify autowiring by name?
View solution
Q. Which of the following contains both date and time?
View solution
Q. Which of the following is advantage of using JDBC connection pool?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Java Programming? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!