Analyze the following code:
Code 1:
int number = 45;
boolean even;
if (number % 2 == 0)
even = true;
else
even = false;
Code 2:
int number = 45;
boolean even = (number % 2 == 0);
a. Code 1 has compile errors.
b. Code 2 has compile errors.
c. Both Code 1 and Code 2 have compile errors.
d. Both Code 1 and Code 2 are correct, but Code 2 is better.
d Both Code 1 and Code 2 are correct. Clearly Code 2 is shorter and better.
Computer Science & Information Technology
You might also like to view...
You cannot use footnotes when a Works Cited page is included
Indicate whether the statement is true or false
Computer Science & Information Technology
The HTML code for a text box consists of an tag with a type attribute of ____.
A. text B. content C. box D. code
Computer Science & Information Technology