Quiz One:
- Question 1: The answer will be 4 because both of the variables are integers and if they are the same then they can be added together. “y” was changed to the value of whatever “x” was so the answer would not be 5.
- Question 2: The output would be “2 versus 2”, because the variable “y” was changed to whatever “x” was which happened to be 2.
- Question 3: The output would be “123” as a string because java can’t add two different types of data so it converts the integers into strings and just smashes them together.
- Question 4: The output would be “15” as a string since the variables are in parenthesis they can be processed together as integers first and then be converted into a string to be added to the “1”.
- Question 5: The output would read “BBC”. I got this wrong because I believed the characters operated as strings but they don’t. I don’t know why the output is 199. Chars start acting as numbers so 66+66+67 which is 199.
- Question 6: This expression is an integer because all of the numbers in the expression are integers so the output would also be an integer.
- Question 7: This expression is a Boolean because the answer to this expression is either true or false.
- Question 8: The output would read 2 because both are the numbers are integers and it only outputs the whole number.
- Question 9: The output would also be 2 because that is what remains after you divide 12 by 5.
-Question 10: The answer would be 2 because C is two spots away from A.
Quiz Two:
-Question 1: The output would be 24 because 3 is greater than 2 and 4 is added to the end regardless of any conditions.
- Question 2: The curly brackets added in this code makes the output produce just a 2. Since 3 is not less than 2 that whole if statement is ignored.
- Question 3: The output would be 23 because the first set of if statements doesn’t apply to the 3 so it goes down to the 2 and then 3 is combined with it automatically. I was wrong and the answer was just 3. The else statement doesn’t apply to x.
- Question 4: This one outputs 23 since the else branch is now evaluated and the 3 is automatically added.
- Question 5: The answer will be 025 because 2 less than 3 so it goes down to the following if statement which is true so it print 0 and then prints 2 then goes to the next if statement which is false so it prints the last 5.
- Question 6: The output is 03 because the first if statement is true so 0 is combined with the false output of the second if statement which is 3.
- Question 7: The output would be 31 because the first if statement is true so the 3 is produced and the second if statement evaluates to true as well so the 1 is produced and is combined with the 3.
- Question 8: The output would be 310 because the second if statement doesn’t have an else statement so both of the print statements belong to the truth part of the if statement so both of them are produced.
- Question 9: The output is going to be 3210 because all else statements have been erased so all the print statements belong to the truth branches and are all outputted.
Quiz Three:
- Question 1: The output will be 02 because the first if statement is true and 0 is produced and the second if statement is also true so the 2 is produced to combine to 02.
- Question 2: The output will be just 0 because the first if statement is true and since the else statement is false and the rest of the program is in curly brackets it is not evaluated.
- Question 3: The output will be 4 because the first if statement is true so (3 + 1) is evaluated and since the rest of the statements are else statements they are not evaluated.
- Question 4: The output will be 43 because the first if statement is true and the second is now evaluated because the else has been removed so a 3 is added. The rest of the statements have else’s so they are not evaluated.
- Question 5: A second else statements have been removed so the first three if statements are evaluated to get 432.
- Question 6: A different else statement has been removed but this statement is false so it goes to the else statement after it which is (3 * 3) and is added to the 43 that was evaluated beforehand.
- Question 7: The output is 100 because the if statement evaluates to true so 100 is produced.
- Question 8: The output is 200 because false & true is false which takes the if statement down to produce what is in the else statement which is 200.
-Question 9: I do not know the answer to this question.
- Question 10: The output is 1 1 2 1 3 1. The integer a isn’t part of the function so its value never changes. “b” on the other hand adds one every time that the function is called.