1.
Significance of the Just-In-Time (JIT) Compiler in Java:
The Just-In-Time (JIT) compiler is a component of the Java Virtual Machine (JVM) that improves the performance of
Java applications by compiling bytecode into native machine code at runtime. This eliminates the need for repeated
interpretation and allows frequently executed code paths to be optimized.
2. Five Keywords in Java:
Some common keywords in Java include: class, static, if, while, and return. These are reserved words used by the Java
language and cannot be used as identifiers.
3. Rules for Naming Identifiers in Java:
Identifiers must start with a letter (A-Z or a-z), a dollar sign ($), or an underscore (_), and subsequent characters can be
letters, digits (0-9), dollar signs, or underscores. Identifiers cannot be Java keywords, and they are case-sensitive.
- Valid: myVar, _value, $name
- Invalid: int, 123abc, my var
4. Can Java Keywords Be Used as Variable Names?
No, Java keywords cannot be used as variable names because they are reserved by the language for specific purposes.
5. Primitive Data Types in Java:
Java supports eight primitive data types: byte, short, int, long, float, double, char, and boolean. These are not objects
and are used for performance-sensitive operations.
6. Implicit vs Explicit Type Conversion:
Implicit conversion (widening) happens automatically when a smaller type is converted to a larger type. Explicit
conversion (narrowing) must be done manually using casting.
Example:
int a = 10;
double b = a; // implicit
int c = (int) b; // explicit
7. Purpose of the switch Statement:
The switch statement allows a variable to be tested against multiple values, making it easier to write code for conditional
branching.
8. Java vs Other Language Compilers:
Unlike C/C++ compilers that generate machine code for specific platforms, the Java compiler translates source code into
bytecode, which is platform-independent and runs on the JVM.
...
50. Convert String to char Array:
String s = "Java";
char[] arr = [Link]();