What Is The Output Of The Following Programp Pre Langjava #106

What is the output of the following program?</p> <pre><code class="language-java"> public class Stack { protected static final int CAPACITY = 100; protected int size,top = -1; protected Object stk[]; public Stack() { stk = new Object[CAPACITY]; } public void push(Object item) { if(size_of_stack==size) { System.out.println("Stack overflow"); return; } else { top++; stk[top]=item; } } public Object pop() { if(top<0) { return -999; } else { Object ele=stk[top]; top--; size_of_stack--; return ele; } } } public class StackDemo { public static void main(String args[]) { Stack myStack = new Stack(); myStack.push(10); Object element1 = myStack.pop(); Object element2 = myStack.pop(); System.out.println(element2); } }</code></pre>

Online Quiz This multiple choice question (MCQ) is related to the book/course gs gs121 Data Structures and Algorithms. It can also be found in gs gs121 Abstract Data Types - Stack using Array - Quiz No.1.


Similar question(s) are as followings:



Online Quizzes of gs121 Data Structures and Algorithms

Choose an organization

Theme Customizer

Gaussian Texture



Gradient Background