Govt Exams
Variable names must start with a letter, underscore (_), or dollar sign ($). They cannot start with digits, contain hyphens, or be reserved keywords.
The 'final' keyword prevents a class from being extended/inherited. A final class cannot have subclasses.
Integer division in Java results in an integer. 5/2 = 2 (remainder is discarded). To get 2.5, at least one operand must be float/double.
Both conditions are true: x == 0 (true) and x != 1 (true). The && (AND) operator returns true when both operands are true.
The logical NOT operator (!) inverts the boolean value. !true becomes false.
The correct syntax is 'datatype[] arrayName = {elements};' or 'datatype[] arrayName = new datatype[size];'
Local variables have scope limited to the method or code block in which they are declared. They cannot be accessed outside that block.
The length() method returns the number of characters in the string "Java", which is 4 characters.
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