Q: An Arithmetic expression in Java involves which Operators or Operations?
Solution: no solution
Q: Choose the Compound Assignment Arithmetic Operators in Java below.
Solution: no solution
Q: What is the output of the below Java code snippet? int a = 2 - - 7; System.out.println(a);
Solution: Minus of Minus is Plus. So 2 - - 7 becomes 2+7.
Q: What is the output of Java code snippet below? short p = 1; short k = p + 2; System.out.println(k);
Solution: Numbers are treated as int type by default. So an int value cannot be assigned to a short variable. You have to type cast the whole expression. short k = (short)(p + 2);
Q: What is the output of Java code snippet? short k=1; k += 2; System.out.println(k);
Solution: Compound assignment operators automatically convert the expression value to the left-hand side data type. k = k + 1; //Error k += 1; //Works k++; //Works
Q: 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);
Solution: a = a - 3; b = b*2; c = c/5;
Q: How do you rewrite the below Java code snippet? int p=10; p = p%3;
Solution: no solution
Q: Which is the arithmetic operator in Java that gives the Remainder of Division?
Solution: //Modulo Division operator // or simply Modulus Operator int a = 14%5; //a holds 4 5)14(2 -10 ------ 4
Q: Arithmetic operators +, -, /, * and % have which Associativity?
Solution: no solution
Q: Between Postfix and Prefix arithmetic operators in Java, which operators have more priority?
Solution: op++, op-- have more priority than --op, ++op.
You Have Score    | /10 |