What is the value after evaluating this expression in Java?
Expressions are evaluated following the rules of PEMDAS. So first left division, 6/3 is evaluated and then all the right side multiplcations and finally addition and subtraction are evaluated.
2 + 6 / 3 * 5 * 2 - 3
Study the below expression
d += 3
d =+ 3
Cannot be replace with anything
d = d+3;
This can be replaced by which shorthand notation?
You want to find if a given number 'a' is even or not. Which expression would you use?
a / 2 == 0
a % 2 == 0
a * 2
Modulo operator % gives you the remainder. If the remainder is 0 after using modulo operator with 2, then it is an even number. If the remainder is 1 then it is odd.
You want to declare a variable named 'months' and store the value of number of months in a year, 12 and it never changes. Which data type will you choose for this variable?
byte uses 8 bits and can hold upto a maximum value of 127. Since we are storing a value of 12, we can use byte. All the other options use more bits and hence occupies more memory to store this small number, which is not efficient.
A comment line is executed by Java compiler. True or False