### Question:
StackDemo { public static int evaluatePostfixExpression(String expression) { ObjectStack stack = new ObjectStack(); String[] parts = expression.split(" +"); for (String part : parts) { try { Integer number = Integer.parseInt(part); stack.push(number); } catch (NumberFormatException e) { if (part.length() != 1) { String message = String.format("Invalid operator: '%s'", part); throw new IllegalArgumentException(message); } operate(stack, part.charAt(0)); } } if (stack.size() != 1) { throw new IllegalArgumentException("Invalid expression"); } return (int) stack.pop(); }  static void main(String[] args); static int evaluatePostfixExpression(String expression);  }### Answer:
@Test void testEvaluatingValidExpressions() { assertEquals(4, evaluatePostfixExpression("8 2 /")); assertEquals(3, evaluatePostfixExpression("-1 8 2 / +")); assertEquals(4, evaluatePostfixExpression("8 -2 / -1 *")); }
@Test void testEvaluatingAnExpressionWithTooManyNumbers() { assertThrows(IllegalArgumentException.class, () -> evaluatePostfixExpression("1 1 1 +")); }
@Test void testEvaluatingAnExpressionWithTooFewNumbers() { assertThrows(IllegalArgumentException.class, () -> evaluatePostfixExpression("1 +")); }
@Test void testEvaluatingAnExpressionWhichDividesByZero() { assertThrows(IllegalArgumentException.class, () -> evaluatePostfixExpression("1 0 /")); assertThrows(IllegalArgumentException.class, () -> evaluatePostfixExpression("1 0 %")); }
@Test void testEvaluatingAnExpressionWithAnUnsupportedOperator() { assertThrows(IllegalArgumentException.class, () -> evaluatePostfixExpression("1 1 ^")); assertThrows(IllegalArgumentException.class, () -> evaluatePostfixExpression("1 1 ++")); }