Govt. Exams
Entrance Exams
Garbage collection in Java is non-deterministic. System.gc() is just a request, not a guarantee. Objects are eligible for GC when unreachable, but actual collection timing varies.
x++ returns 5 (then increments to 6), ++x increments to 7 and returns 7. Sum = 5+7 = 12. Note: Actual result may vary due to JVM optimization but typically 11 or 12.
Both conditions are true: x == 0 (true) and x != 1 (true). The && (AND) operator returns true when both operands are true.
Local variables have scope limited to the method or code block in which they are declared. They cannot be accessed outside that block.
String concatenation works left to right. 10 + 20 = 30 (integer addition), then 30 + "Java" = "30Java" (string concatenation).
The post-increment operator (a++) returns the value before incrementing. So b = 5, then a becomes 6. Output: 6 5