Question: 7. What will be the output of the following Java program?<div class="hk1_style-wrap4"><div class="hk1_style-wrap3"><div class="hk1_style-wrap2"><div class="hk1_style-wrap"><div class="hk1_style"><div class="java"><ol><li class="li1"><pre class="de1"> <span class="kw1">import</span> <span class="co2">java.util.*</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw1">public</span> <span class="kw1">class</span> genericstack <span class="sy0">&lt;</span>E<span class="sy0">&gt;</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">{</span></pre></li><li class="li1"><pre class="de1"> <span class="kw3">Stack</span> <span class="sy0">&lt;</span>E<span class="sy0">&gt;</span> stk <span class="sy0">=</span> <span class="kw1">new</span> <span class="kw3">Stack</span> <span class="sy0">&lt;</span>E<span class="sy0">&gt;</span><span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw1">public</span> <span class="kw4">void</span> push<span class="br0">(</span>E obj<span class="br0">)</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">{</span></pre></li><li class="li1"><pre class="de1"> stk.<span class="me1">push</span><span class="br0">(</span>obj<span class="br0">)</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">}</span></pre></li><li class="li1"><pre class="de1"> <span class="kw1">public</span> E pop<span class="br0">(</span><span class="br0">)</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">{</span></pre></li><li class="li1"><pre class="de1"> E obj <span class="sy0">=</span> stk.<span class="me1">pop</span><span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw1">return</span> obj<span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">}</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">}</span></pre></li><li class="li1"><pre class="de1"> <span class="kw1">class</span> Output</pre></li><li class="li1"><pre class="de1"> <span class="br0">{</span></pre></li><li class="li1"><pre class="de1"> <span class="kw1">public</span> <span class="kw1">static</span> <span class="kw4">void</span> main<span class="br0">(</span><span class="kw3">String</span> args<span class="br0">[</span><span class="br0">]</span><span class="br0">)</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">{</span></pre></li><li class="li1"><pre class="de1"> genericstack <span class="sy0">&lt;</span>Integer<span class="sy0">&gt;</span> gs <span class="sy0">=</span> <span class="kw1">new</span> genericstack<span class="sy0">&lt;</span>Integer<span class="sy0">&gt;</span><span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> gs.<span class="me1">push</span><span class="br0">(</span><span class="nu0">36</span><span class="br0">)</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="kw3">System</span>.<span class="me1">out</span>.<span class="me1">println</span><span class="br0">(</span>gs.<span class="me1">pop</span><span class="br0">(</span><span class="br0">)</span><span class="br0">)</span><span class="sy0">;</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">}</span></pre></li><li class="li1"><pre class="de1"> <span class="br0">}</span></pre></li></ol></div></div></div></div></div></div>
Options:
0
36
Runtime Error
Compilation Error
Answer: B