Assertions

Practice Questions

Computer Science › Assertions

Questions
2
1

Which of the following code excerpts would output "10"?

2

True or False.

The assertion in this code snippet is to prevent users from inputting bad data.

public class UserInput {

int userInput;

public static void main(String[] args) {

assertTrue(isInteger(args[0]));

userInput = args[0];

userInput = 25 - userInput;

}

}

Return to subject