java
java
There are 8 types of primitive data types- int, char, boolean, byte, long,
float, short, double.
2. What is the size of float and double in java?
The size of float and double in java is 32 and 64.
3. Find the output of the following code.
int Integer = 24;
char String = ‘I’;
System.out.print(Integer);
System.out.print(String)
Answer: 24 I will be printed.
4. Find the output of the following program.
public class Solution{
public static void main(String[] args){
short x = 10;
x = x * 5;
System.out.print(x);
}
} Options: 50, 10, Compile Error, Exception
Answer: This will give compile error - “Lossy conversion from int to
short”
5. Find the output of the following program.
public class Solution{
public static void main(String[] args){
byte x = 127;
x++;
x++;
System.out.print(x);
} Options: -127, 127, 129, 2
} Answer: - 127 - Range of byte data in java is -128 to 127. But the
byte data type in java is cyclic in nature.