Question 8
Consider the Java code given below.
public class AssertTest { public static double computeTax(double salary, double investments) { double taxableIncome = 0; double taxRate = 0.2; double tax = 0; assert salary > 0 ; // assert-1 assert investments > 0; // assert-2 taxableIncome = salary - investments; assert taxableIncome >= 0 ; // assert-3 tax = taxableIncome * taxRate; return tax; }
public static void main(String[] args) { double salary = 120000; double investments = 0; assert salary > 0 ; // assert-4 double tax = computeTax(salary, investments); }}Identify the first assert statement that throws the AssertionError when the class is executed as:
java -ea AssertTest