Java Quiz 1 : Data Types, Variables and Arrays By Tejas Chaudhari - August 14, 2021 FacebookTwitterPinterestWhatsApp Welcome to your Java Quiz 1 : Data Types, Variables and Arrays 1. What is the range of short data type in Java?a) -128 to 127b) -32768 to 32767c) -2147483648 to 2147483647d) None of the mentioned 2. What is the range of byte data type in Java?a) -128 to 127b) -32768 to 32767c) -2147483648 to 2147483647d) None of the mentioned 3. Which of the following are legal lines of Java code? 1. int w = (int)888.8; 2. byte x = (byte)100L; 3. long y = (byte)100; 4. byte z = (byte)100L;a) 1 and 2b) 2 and 3c) 3 and 4d) All statements are correct 4. An expression involving byte, int, and literal numbers is promoted to which of these?a) intb) longc) byted) float 5. Which of these literals can be contained in float data type variable?a) -1.7e+308b) -3.4e+038c) +1.7e+308d) -3.4e+050 6. Which data type value is returned by all transcendental math functions?a) intb) floatc) doubled) long 7. What will be the output of the following Java code? class average { public static void main(String args[]) { double num[] = {5.5, 10.1, 11, 12.8, 56.9, 2.5}; double result; result = 0; for (int i = 0; i < 6; ++i) result = result + num[i]; System.out.print(result/6); } } a) 16.34b) 16.566666644c) 16.46666666666667d) 16.46666666666666 8. What will be the output of the following Java statement? class output { public static void main(String args[]) { double a, b,c; a = 3.0/0; b = 0/4.0; c=0/0.0; System.out.println(a); System.out.println(b); System.out.println(c); } } a) Infinityb) 0.0c) NaNd) all of the mentioned 9. What will be the output of the following Java code? class increment { public static void main(String args[]) { int g = 3; System.out.print(++g * 8); } } a) 25b) 24c) 32d) 33 10. What will be the output of the following Java code? class area { public static void main(String args[]) { double r, pi, a; r = 9.8; pi = 3.14; a = pi * r * r; System.out.println(a); } } a) 301.5656b) 301c) 301.56d) 301.56560000 11. What is the numerical range of a char data type in Java?a) -128 to 127b) 0 to 256c) 0 to 32767d) 0 to 65535 12. Which of these coding types is used for data type characters in Java?a) ASCIIb) ISO-LATIN-1c) UNICODEd) None of the mentioned 13. Which of these values can a boolean variable contain?a) True & Falseb) 0 & 1c) Any integer valued) true 14. Which of these occupy first 0 to 127 in Unicode character set used for characters in Java?a) ASCIIb) ISO-LATIN-1c) None of the mentionedd) ASCII and ISO-LATIN1 15. Which one is a valid declaration of a boolean?a) boolean b1 = 1;b) boolean b2 = ‘false’;c) boolean b3 = false;d) boolean b4 = ‘true’ 16. What will be the output of the following Java program? class array_output { public static void main(String args[]) { char array_variable [] = new char[10]; for (int i = 0; i < 10; ++i) { array_variable[i] = 'i'; System.out.print(array_variable[i] + "" ); i++; } } } a) i i i i ib) 0 1 2 3 4c) i j k l md) None of the mentioned 17. What will be the output of the following Java program? class mainclass { public static void main(String args[]) { char a = 'A'; a++; System.out.print((int)a); } } a) 66b) 67c) 65d) 64 18. What will be the output of the following Java program? class mainclass { public static void main(String args[]) { boolean var1 = true; boolean var2 = false; if (var1) System.out.println(var1); else System.out.println(var2); } } a) 0b) 1c) trued) false 19. What will be the output of the following Java code? class booloperators { public static void main(String args[]) { boolean var1 = true; boolean var2 = false; System.out.println((var1 & var2)); } } a) 0b) 1c) trued) false 20. What will be the output of the following Java code? class asciicodes { public static void main(String args[]) { char var1 = 'A'; char var2 = 'a'; System.out.println((int)var1 + " " + (int)var2); } } a) 162b) 65 97c) 67 95d) 66 98 Time is Up!