Java MCQ Questions
6. 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); } }
-127
7. Select the valid statement. char[] ch = new char(5) char[] ch = new char[5] char[] ch = new char() char[] ch = new char[]
char[] ch = new char[5]
3. Automatic type conversion is possible in which of the possible cases?
INT to long
2. What is the size of float and double in java?
32 and 64
10. Select the valid statement to declare and initialize an array. int[] A = {} int[] A = {1, 2, 3} int[] A = (1, 2, 3) int[][] A = {1,2,3}
10. int[] A = {1, 2, 3}
8. Find the output of the following program. public class Solution{ public static void main(String[] args){ int[] x = {120, 200, 016}; for(int i = 0; i < x.length; i++){ System.out.print(x[i] + " ") ; } } }
120 200 14
4. Find the output of the following code. int Integer = 24; char String = 'I'; System.out.print(Integer); System.out.print(String);
24 I
1. Number of primitive data types in Java are?
8
5. 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); } }
Compile error
9. When an array is passed to a method, what does the method receive? The reference of the array A copy of the array Length of the array Copy of first element
The reference of the array