InterviewSolution
| 1. |
What Is The Output Of This Program? 1. Import Java.util.*; 2. Class Stack { 3. Public Static Void Main(string Args[]) { 4. Stack Obj = New Stack(); 5. Obj.push(new Integer(3)); 6. Obj.push(new Integer(2)); 7. Obj.pop(); 8. Obj.push(new Integer(5)); 9. System.out.println(obj); 10. } 11. } |
|
Answer» push() and POP() are standard functions of the class stack, push() inserts in the stack and pop removes from the stack. 3 & 2 are inserted using push() the pop() is used which removes 2 from the stack then again push is used to insert 5 HENCE stack contains ELEMENTS 3 & 5. Output: $ JAVAC stack.JAVA push() and pop() are standard functions of the class stack, push() inserts in the stack and pop removes from the stack. 3 & 2 are inserted using push() the pop() is used which removes 2 from the stack then again push is used to insert 5 hence stack contains elements 3 & 5. Output: $ javac stack.java |
|