Govt. Exams
Entrance Exams
charAt() uses 0-based indexing. Index 1 refers to the second character, which is 'e' in "Hello".
Multi-line comments in Java use /* */ syntax. Single-line comments use //. Other syntaxes are for different languages.
The 'f' suffix indicates a float literal. The output will be 5.5 (trailing zeros are not shown in standard printing).
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.
The logical NOT operator (!) inverts the boolean value. !true becomes false.
The += operator adds the right operand to the left operand. x += 3 is equivalent to x = x + 3, so 5 + 3 = 8.
The 'final' keyword is used to declare constants in Java. Once assigned, the value cannot be changed.
Java uses the syntax 'datatype variableName = value;' for variable declaration.