For this Question: Your task is to implement a stack using an array and perform given queries

<b>Note</b>: Description of each query is given in the <b>input and output format</b>User task:
Since this will be a functional problem, you don't have to take input. You just have to complete the functions:
 <b>push()</b>:- that takes the integer to be added and the maximum size of the array as a parameter.
 <b>pop()</b>:-   that takes no parameter.
 <b>top()</b> :-   that takes no parameter.

Constraints:
1 <= N(number of queries) <= 10<sup>3</sup>During a <b>pop</b> operation if the stack is empty you need to print "<b>Stack underflow</b>", 
during <b>push</b> operation, if the maximum size of the array is reached you need to print "<b>Stack overflow</b>", <br>      during <b>top</b> operation, you need to print the element which is at the top
if the stack is empty you need to print "<b>Empty stack</b>".

<b>Note</b>:- Each message or element is to be printed on a new line
Sample Input:-
6 3
pop
push 3
push 2
push 4 
push 6
top

Sample Output:-
Stack underflow
Stack overflow
4

Explanation:-
Here maximum size of the array is 3, so element 6 can not be added to stack

Sample input:-
8 4
push 2
top
push 4
top
push 6
top
push 8
top

Sample Output:-
2
4
6
8
, I have written this Solution Code:     void push(int x,int k) 
    { 
        if (top >= k-1) { 
            System.out.println("Stack overflow"); 
          
        } 
        else { 
            a[++top] = x; 
            
        } 
    } 
  
    void pop() 
    { 
        if (top < 0) { 
            System.out.println("Stack underflow"); 
            
        } 
        else { 
            int x = a[top--]; 
            
        } 
    } 
  
    void top() 
    { 
        if (top < 0) { 
            System.out.println("Empty stack"); 
            
        } 
        else { 
            int x = a[top]; 
            System.out.println(x);
            
        } 
    } , In this Programming Language: Java, Now tell me if this Code is compilable or not?