Arithmetic Operators and Constants Quiz
17 Questions
3 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the purpose of arithmetic operators in Java?

  • To declare variables
  • To assign values to variables
  • To perform operations on variables (correct)
  • To print output to the console

Which operator is used to add two numbers in Java?

  • + (correct)
  • *
  • /
  • -

What is the purpose of the assignment operator in Java?

  • To perform mathematical operations
  • To compare two values
  • To assign values to variables (correct)
  • To declare variables

What is the result of the expression: $5 * 3$?

<p>15 (D)</p> Signup and view all the answers

In the expression: $balance = balance - 100;$, what is the purpose of the minus (-) operator?

<p>To perform subtraction (D)</p> Signup and view all the answers

What does the modulus (%) operator do in Java?

<p>Returns the remainder of a division operation (C)</p> Signup and view all the answers

What operator is used to concatenate strings in Java?

<ul> <li>(D)</li> </ul> Signup and view all the answers

In Java, which operator is used for subtraction?

<ul> <li>(A)</li> </ul> Signup and view all the answers

What is the result of 7 / 4 if both operands are integers in Java?

<p>1 (C)</p> Signup and view all the answers

What does the modulus operator (%) return in Java?

<p>Remainder after division (B)</p> Signup and view all the answers

In Java, what operator is used to perform multiplication?

<ul> <li>(B)</li> </ul> Signup and view all the answers

How is the average value calculated in Java using the division operator?

<p>(mathsMark + progMark) / 2 (A)</p> Signup and view all the answers

What is the result of 11 / 4 if stored in an int variable in Java?

<p>2 (A)</p> Signup and view all the answers

What does the modulus operator return for 40 % 40 in Java?

<p>0 (B)</p> Signup and view all the answers

In Java, which operator has the lowest level of precedence?

<p>= (B)</p> Signup and view all the answers

What is the purpose of using brackets in arithmetic expressions in Java?

<p>To override operator precedence (B)</p> Signup and view all the answers

'Associativity' refers to the order of operation of operators with the same precedence in Java. How do arithmetic operators work from left to right?

<ul> <li>% + - / (C)</li> </ul> Signup and view all the answers

More Like This

Use Quizgecko on...
Browser
Browser