Values and Data types II

Values and Data types II

Arrays and Data Types, Data Type Limits and Overflow, String Immutability, Type Conversion with Expressions, Arrays and Default Values, Floating-Point Precision, Variable Initialization

1 / 10

What will the following code produce?

int[] arr = new int[5];
System.out.println(arr[2]);

2 / 10

Which of the following is true about arrays in Java?

3 / 10

What is the result of this code?

float f = 3.4f;
double d = f;
System.out.println(d);

4 / 10

What will the following code print?

boolean b = true;
System.out.println(b ? “Yes” : “No”);

5 / 10

What will the following code output?

int a = Integer.MAX_VALUE;
int b = a + 1;
System.out.println(b);

6 / 10

What happens when the following code is executed?

String s = “Hello”;
s.concat(” World”);
System.out.println(s);

7 / 10

What will the following code print?

byte a = 40;
byte b = 50;
byte c = (byte) (a * b);
System.out.println(c);

8 / 10

Consider the following array declaration. What will be the output of the code?

boolean[] arr = new boolean[3];
System.out.println(arr[1]);

9 / 10

What will the following code output?

double d = 0.1 + 0.2;
System.out.println(d == 0.3);

10 / 10

What happens when the following code is executed?

int x;
System.out.println(x);

Your score is

Scroll to Top