Govt. Exams
Entrance Exams
The 'final' keyword when applied to a class prevents it from being extended or inherited. This is a fundamental OOP concept in Java used to restrict inheritance.
This uses the ternary operator (conditional operator). The condition 5 > 3 is true, so it returns the value after the '?', which is "Yes".
'thread' is not a Java keyword. 'synchronized', 'volatile', and 'transient' are all valid Java keywords used for special purposes.
'break' statement exits the innermost loop or switch statement. It doesn't skip the current iteration (that's 'continue') and doesn't terminate the entire program.
When dividing two integers, Java performs integer division and returns an integer result. 10 / 3 = 3 (remainder is discarded). To get decimal result, at least one operand should be a float or double.
In Java, the 'long' data type is always 64 bits, regardless of the platform. This is one of Java's strengths - its size specifications are platform-independent.
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.