Vidyalelo
Data Structure · Q71

Introduction to Data Structures

Programming · Data Structure · question 71

Q71

What is the functionality of the following piece of Java code? Assume: 'a' is a non empty array of integers, the Stack class creates an array of specified size and provides a top pointer indicating TOS(top of stack), push and pop have normal meaning. public void some_function(int[] a) Stack S=new Stack(a.length); int[] b=new int[a.length]; for(int i=0;i<a.length;i++) S.push(a[i]); for(int i=0;i<a.length;i++) b[i]=(int)(S.pop()); System.out.println("output :"); for(int i=0;i<b.length;i++) System.out.println(b[i]);

A.
print alternate elements of array
B.
duplicate the given array
C.
parentheses matching
D.
reverse the array
Answer

Answer: Option D

Solution

Answer: Option D
No explanation is given for this question Let's Discuss on Board