Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+15 votes

In boolean methods, do they always have to return either true or false or is there other things that are possible to be returned from these methods?

asked in CSC211_Winter2018 by (1 point)

2 Answers

+10 votes

Boolean results are used to determine whether a condition is true or false, and allow us to write programs that decide whether to execute some code or not. Therefore they do not have any other possible return statements other than true or false.

answered by (1 point)
+8 votes

Jason is exactly correct. A boolean value can only be true or false. That's it. Whether a boolean value is returned from a method or a variable is created of type boolean, the only possible values are true or false.

answered by (1 point)
...