Home / MCQ Bank / Computer
Computer Interfaces And Abstract Classes

What will be the output of the following Java 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()); } }

Select the best option to verify your answer:
Show Correct Answer
Correct Answer: Option D • Hello 36

Related Computer Questions

In Datasheet View, what appears at the top of each column? What is the return type of the IndexOf() method when applied to a string in C#? What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { int a = 5, c; void *p = &a; double b = 3.14; p = &b; c = a + b; cout << c << '\n' << p; return 0; } What will be the output of the following Java code? class Output { public static void main(String args[]) { byte a[] = { 65, 66, 67, 68, 69, 70 }; byte b[] = { 71, 72, 73, 74, 75, 76 }; System.arraycopy(a, 2, b, 1, a.length-2); System.out.print(new String(a) + " " + new String(b)); } } Which symbol is used to declare the preprocessor directives?