Java MCQ Questions and Answers on Arithmetic Operators 1

Study and learn Java MCQ questions and answers on Arithmetic Operators and their priorities. Attend job interviews easily with these Multiple Choice Questions.

Go through Java Theory Notes on Arithmetic Operators before studying questions.



1) An Arithmetic expression in Java involves which Operators or Operations?
A) Addition (+), Subtraction (-)
B) Multiplication (*), Division (/)
C) Modulo Division (%), Increment/Decrement (++/--), Unary Minus (-), Unary Plus (+)
D) All the above
Answer [=]
Answer[=]
2) Choose the Compound Assignment Arithmetic Operators in Java below.
A) +=, -=
B) *=, /=
C) %=
D) All the above
Answer [=]
Answer[=]
3)
What is the output of the below Java code snippet?
int a = 2 - - 7;
System.out.println(a);
A) -5
B) 10
C) 9
D) Compiler Error
Answer [=]
Answer[=]
4)
What is the output of Java code snippet below?
short p = 1;
short k = p + 2;
System.out.println(k);
A) 1
B) 2
C) 3
D) Compiler error
Answer [=]
Answer[=]
5)
What is the output of Java code snippet?
short k=1;
k += 2;
System.out.println(k);
A) 1
B) 2
C) 3
D) Compiler error about Type Casting
Answer [=]
Answer[=]
6)
What is the output of the Java code snippet?
int a=5, b=10, c=15;
a -= 3;
b *= 2;
c /= 5;
System.out.println(a +" " + b + " " + c);
A) 2 20 3
B) 2 20 5
C) 2 10 5
D) -2 20 3
Answer [=]
Answer[=]
7)
How do you rewrite the below Java code snippet?
int p=10;
p = p%3;
A)
p=%3;
B)
p%=3;
C)
p=3%;
D) None of the above
Answer [=]
Answer[=]


 

8) Which is the arithmetic operator in Java that gives the Remainder of Division?
A) /
B) @
C) %
D) &
Answer [=]
Answer[=]
9) Arithmetic operators +, -, /, *  and % have which Associativity?
A) Right to Left
B) Left to Right
C) Right to Right
D) Left to Left
Answer [=]
Answer[=]
10) Between Postfix and Prefix arithmetic operators in Java, which operators have more priority?
A) Postfix operators have more priority than Prefix operators
B) Prefix operators have more priority than Postfix operators
C) Both Prefix and Postfix operators have equal priority
D) None of the above
Answer [=]
Answer[=]
11) Among Postfix Decrement and Prefix Increment operators in Java, which operator has less priority?
A) Postfix Decrement has less priority than Prefix Increment
B) Prefix Increment has less priority than Postfix Decrement
C) Both operators have same priority
D) None of the above
Answer [=]
Answer[=]
12) Increment and Decrement arithmetic operators in Java has which Associativity?
A) Left to Right
B) Right to Left
C) Left to Left
D) Right to Right
Answer [=]
Answer[=]
13) Choose the correct statement about Java Operators +, -, *, / and %.
A) + and - have equal priority
B) * and / have equal priority
C) / and % have equal priority
D) All the above
Answer [=]
Answer[=]
14) Among the operator groups (++, --) and (+, -, *, /, %) in Java, which group has higher priority? 
A) (++, --) group has higher priority than (+, -, *, /, %) group
B) (++, --) group has lower priority than (+, -, *, /, %) group
C) (++, --) group and (+, -, *, /, %) group have equal priority
D) None of the above
Answer [=]
Answer[=]


 

15)
What is the output of the Java code snippet?
int a=10, b=6;
int c = a+b*5;
System.out.println(c);
A) 40
B) 50
C) 80
D) Compiler error
Answer [=]
Answer[=]
16)
What is the output of the Java code snippet?
int a=10, b=5, c=3;
int d = a+c/2*b;
System.out.println(d);
A) 17.5
B) 32.5
C) 15
D) 30
Answer [=]
Answer[=]
17)
What is the output of the Java code snippet?
int a=5, b=6;
if(a++ == --b)
{
  System.out.println("5=5");
}
else
{
  System.out.println("NONE");
}
A) NONE
B) 5=5
C) Compiler error
D) None of the above
Answer [=]
Answer[=]
18)
What is the output of the Java code snippet?
int a=6, b=5;
if(++b == a--)
{
  System.out.println("RABBIT");
}
else
{
  System.out.println("BUNNY");
}
A) RABBIT
B) BUNNY
C) Compiler error
D) None of the above
Answer [=]
Answer[=]
19)
What is the output of the Java code snippet?
int a=10, b=20;
int c = a++*2;
int d = --b*2;
System.out.println(c +"," + d);
A) 20,40
B) 22,40
C) 20,38
D) 22,38
Answer [=]
Answer[=]
20) Choose the correct statement about Java Prefix and Postfix operations.
A) Prefix operation is carried out immediately and the variable value will be incremented or decremented accordingly
B) Postfix operation is carried out on the next line or statement. So the variable value will not change.
C) A and B
D) None of the above
Answer [=]
Answer[=]


Like or Share

Show some care. Like or Subscribe. [FB]...[Youtube]

C MCQ App by ExamTray 

Android APP

Java MCQ App by ExamTray 

Android APP
ALL MCQ App by ExamTray Android APP

Ad

 

Try Some Java Books

Book Price
1. Java - The Complete Reference  Check Price
2. Core Java: An Integrated Approach, Black Book Check Price
3. Java All-in-One for Dummies Check Price
4. OCP Java SE 8: Programmer II Check Price
5. Programming with Java Check Price
6. Head First Java Check Price

We may get some affiliate commission for the above purchases.