Govt. Exams
Entrance Exams
'this' is a reference to the current object instance. It's used to distinguish instance variables from parameters and to call other constructors.
Explicit casting from double to int truncates the decimal part. 5.7 becomes 5 (not rounded).
Ternary operator: condition ? trueValue : falseValue. Since 10 > 20 is false, "B" is printed.
Both syntaxes are valid in Java for declaring 2D arrays. The brackets can be placed after the type or variable name.
String concatenation: "5" + 3 becomes "53", then "53" + 2 becomes "532". Once a String is involved, + performs concatenation.
Operators *, / have same precedence and are evaluated left to right: ((10 * 2) / 5) * 2 = (20 / 5) * 2 = 4 * 2 = 8.
Option A fails (300 exceeds byte range). Option B works with explicit casting. Option C works (char to int conversion is implicit).
&& has higher precedence than ||. So: (true && false) || true = false || true = true.
Both 'L' and 'l' suffixes are valid for long literals in Java, though 'L' is preferred as it's less confusing with '1'.
++x increments x to 6 and uses it, then x++ uses 6 and increments to 7. So 6 + 6 = 12.