Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class SampleDemo {
    public static void main(String args[]) {
        Sample <Integer> obj = new Sample<Integer>();
        obj.push(36);
        System.out.println(obj.pop());
    }
}
class Sample<E>
{
    Stack <E> ob = new Stack <E>();
    public void push(E obj) {
        ob.push(obj);
    }
    public E pop() {
        E obj = ob.pop();
        return obj;
    }
}


36
Some Other Output
Compilation Error
Runtime Error

Doubts

Problems

Topic: Java Generics

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App