Programming  Java  Operators

Answer each question, once completed click submit.

1. Which of the following can be operands of arithmetic operators?

Numeric Boolean Characters Both Numeric & Characters

Workspace

Discuss

2. Modulus operator, %, can be applied to which of these?

Integers Floating – point numbers Both Integers and floating – point numbers. None of the mentioned

Workspace

Discuss

3. With x = 0, which of the following are legal lines of Java code for changing the value of x to 1?
1. x++;
2. x = x + 1;
3. x += 1;
4. x =+ 1;

1, 2 & 3 1 & 4 1, 2, 3 & 4 3 & 2

Workspace

Discuss

4. Decrement operator, –, decreases value of variable by what number?

1 2 3 4

Workspace

Discuss

5. Which of these statements are incorrect?

Assignment operators are more efficiently implemented by Java run-time system than their equivalent long forms. Assignment operators run faster than their equivalent long forms. Assignment operators can be used only with numeric and character data type. None

Workspace

Discuss

6. What should be expression1 evaluate to in using ternary operator as in this line?
expression1 ? expression2 : expression3

Integer Floating – point numbers Boolean None of the mentioned

Workspace

Discuss

7. What is the value stored in x in following lines of code?
int x, y, z;
x = 0;
y = 1;
x = y = z = 8;

0 1 9 8

Workspace

Discuss

8. What is the order of precedence (highest to lowest) of following operators?
1. &
2. ^
3. ?:

1 -> 2 -> 3 2 -> 1 -> 3 3 -> 2 -> 1 2 -> 3 -> 1

Workspace

Discuss

9. Which of these statements are incorrect?

Equal to operator has least precedence. Brackets () have highest precedence. Division operator, /, has higher precedence than multiplication operator. Addition operator, +, and subtraction operator have equal precedence.

Workspace

Discuss

10. What is the output of relational operators?

Integer Boolean Characters Double

Workspace

Discuss

11. Evaluate the value of the expression? 6 - 2 + 10 % 4 + 7

10 12 13 14

Workspace

Discuss

12. Which of the following assignment operator does not exist in Java?

>> %= >>> <<<

Workspace

Discuss

13. What is/are highest order precedence operator(s) in Java?

( ) { } both a and b None of these

Workspace

Discuss

14. The order of precedence from highest to lowest is :

&&, /, |,{} %, <=, &&, = <, !, ==, ++ +, -, [], !=

Workspace

Discuss

15. The && and || operators

Combine two numeric values Compare two boolean values Combine two boolean values Compare two boolean values

Workspace

Discuss
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15