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

The following C# code is run on single level of inheritance. What will be the Correct statement in the following C# code? class sample { int i = 10; int j = 20; public void display() { Console.WriteLine("base method "); } } class sample1 : sample { public int s = 30; } class Program { static void Main(string[] args) { sample1 obj = new sample1(); Console.WriteLine("{0}, {1}, {2}", obj.i, obj.j, obj.s); obj.display(); Console.ReadLine(); } } What would be the size of the following union declaration? (Assuming size of double = 8, size of int = 4, size of char = 1) #include <stdio.h> union uTemp { double a; int b[10]; char c; }u; To force Hive to be more verbose, it can be started with ______ What will be the output of the following C code? #include <stdio.h> void main() { int i = 0, j = 0; for (i = 0;i < 5; i++) { for (j = 0;j < 4; j++) { if (i > 1) break; } printf("Hi \n"); } } JavaScript code between a pair of “script” tags are called