Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

Practice MT2: Q1

+7 votes
What are the answers to question 1 (true/false) parts a-g?  (and why?)
asked Jan 25, 2015 in (Winter 14) by Forrest Stonedahl (3,438 points)
Does anyone know which one is wrong/know why?

1 Answer

+2 votes
a. False. we use the .equals() method to compare strings

b. False. Usually when more than one return statement is in a method, it is because they follow certain conditions. For example. we could use two returns with an if statement. If this > return THIS, Else > return THAT. both values do not get returned.

c. False. Void methods can not return, therefore having a return in the method will not do anything and most likely cause an error.

d. True. A method signature happens to be the method name and the number and types of its parameters.

e. True. This one is tricky because one may see it as asking if a println is used for keyboard input. However, it's actually saying a println is used PRIOR to keyboard input for prompting. which is true!

f. True. && || and ! all happen to be logical operators.

g. True. starting the value at zero will allow the variable be initalized outside of the loop. this will start the value of the variable where it needs to be.. mathmatically.
answered Jan 26, 2015 by Ethan Blatti (100 points)
There is *one* incorrect answer in the list above... can anyone find it?
is the incorrect answer, a?
Nope, (g) is the incorrect one -- starting with a value of ZERO only works if none of the numbers are negative.  If you have negative numbers, you need your variable to start at a value that is smaller than any of the numbers you may encounter... e.g. -999999 (or, even better, you might use the constant Integer.MIN_VALUE).
...