CPSC 250 Fundamental Java Flashcards
<p>1 + 2</p>
<p>3</p>
<p>1 / 2</p>
<p>0</p>
<p>1 / 2.0</p>
<p>0.5</p>
<p>1 + "2"</p>
<p>"12" (String)</p>
<p>1 + 7 - 9 * 2</p>
<p>-10</p>
<p>What is operator precedence for: () ++ + -- - * / %</p>
<p>First:() Second:++ -- (prefix before/postfix after) + - Third: * / % For Ties: First-parsed=First Evaluated</p>
<p>What is % ?</p>
<p>Modulus: gives the remainder for division</p>
<p>1 + 2</p>
<p>3</p>
<p>1.0 + 2.0</p>
<p>3.0</p>
<p>1.0 / 2.0</p>
<p>0.5</p>
<p>1.0 / 2</p>
<p>0.5</p>
<p>1 / 2.0</p>
<p>0.5</p>
<p>"1" + 2</p>
<p>"12" (String)</p>
<p>1 + "2"</p>
<p>"12" (String)</p>
<p>1 + 2 + "3"</p>
<p>"33" (String)</p>
<p>7 / 2 + 10 % 4</p>
<p>5</p>
<p>1 + 7 - 9 * 2</p>
<p>-10</p>
<p>10 % 3 + 4 * 8</p>
<p>33</p>
<p>4 - 1 / 2 * -3</p>
<p>4</p>
<p>4 - 1 / 2 * -3</p>
<p>4</p>
<p>6 % 7 + 8 - 9</p>
<p>5</p>
<p>6.5 % 2.5</p>
<p>1.5</p>
<p>6.5 % 2.5</p>
<p>1.5</p>
<p>int a = 2; int b = 4; a++ * ++b</p>
<p>10</p>
<p>1 / 2</p>
<p>0</p>