Govt. Exams
Entrance Exams
The += operator is an assignment operator that adds the right operand to the left operand and assigns the result. So x += 3 means x = x + 3, which is 5 + 3 = 8.
When + operator is used with numeric values first, they are added (10 + 20 = 30), and then concatenated with the string "Java", resulting in "30Java".
The 'final' keyword is used to declare constants in Java. Once a final variable is assigned a value, it cannot be changed. 'const' is a reserved keyword but not used in Java.
Method names must start with a letter, underscore, or dollar sign. '_myMethod()' is valid. Names cannot start with digits, contain hyphens, or spaces.
The compound assignment operator += means x = x + 3. So 5 + 3 = 8.
Both operands are integers, so integer division is performed. Result is 3 (not 3.33). To get decimal, at least one operand must be float/double.
The 'instanceof' operator is used to check if an object is an instance of a specific class or implements a specific interface.
The 'super' keyword is used to refer to parent class members and invoke parent class constructors.
Variable names can contain letters, digits, underscores, and dollar signs, but cannot start with a digit or contain hyphens or dots.
'const' is not a Java keyword. The correct convention for constants is public static final. Option D also works but C follows the standard convention.