JAVA-Data Types, Variables and Arrays

¡Supera tus tareas y exámenes ahora con Quizwiz!

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'

c

Which of these can not be used for a variable name in Java? a) identifier b) keyword c) identifier & keyword d) None of the mentioned

b

Literal can be of which of these data types? a) integer b) float c) boolean d) all of the mentioned

d

Literals in java must be preceded by which of these? a) L b) l c) D d) L and I

d

What is the numerical range of a char in Java? a) -128 to 127 b) 0 to 256 c) 0 to 32767 d) 0 to 65535

d

What is the range of data type short in Java? a) -128 to 127 b) -32768 to 32767 c) -2147483648 to 2147483647 d) None of the mentioned

b

Which of these values can a boolean variable contain? a) True & False b) 0 & 1 c) Any integer value d) true

a

Which of these is necessary to specify at time of array initialization? a) Row b) Column c) Both Row and Column d) None of the mentioned

a

What is the range of data type byte in Java? a) -128 to 127 b) -32768 to 32767 c) -2147483648 to 2147483647 d) None of the mentioned

a

Which of these is an incorrect Statement? a) It is necessary to use new operator to initialize an array. b) Array can be initialized using comma separated expressions surrounded by curly braces. c) Array can be initialized when they are declared. d) None of the mentioned

a

What is the output of this program? 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.34 b) 16.566666644 c) 16.46666666666667 d) 16.46666666666666

c

Which of these is returned by operators &, ? a) Integer b) Boolean c) Character d) Float

c

What is the output of this program? class conversion { public static void main(String args[]) { double a = 295.04; int b = 300; byte c = (byte) a; byte d = (byte) b; System.out.println(c + " " + d); } } a) 38 43 b) 39 44 c) 295 300 d) 295.04 300

b

What is the output of this program? class increment { public static void main(String args[]) { int g = 3; System.out.print(++g * 8); } } a) 25 b) 24 c) 32 d) 33

c

What is the output of this 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) 0 b) 1 c) true d) false

c

An expression involving byte, int, and literal numbers is promoted to which of these? a) int b) long c) byte d) float

a

Which of these coding types is used for data type characters in Java? a) ASCII b) ISO-LATIN-1 c) UNICODE d) None of the mentioned

c

Which of these operators is used to allocate memory to array variable in Java? a) malloc b) alloc c) new d) new malloc

c

What is the output of this 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] + ""); } } } a) 1 2 3 4 5 6 7 8 9 10 b) 0 1 2 3 4 5 6 7 8 9 10 c) i j k l m n o p q r d) i i i i i i i i i i

d

What is the output of this program? class booloperators { public static void main(String args[]) { boolean var1 = true; boolean var2 = false; System.out.println((var2 & var2)); } } a) 0 b) 1 c) true d) false

d

What is the output of this program? class mainclass { public static void main(String args[]) { char a = 'A'; a++; System.out.print((int)a); } } a) 66 b) 67 c) 65 d) 64

a

Which of these is data type long literal? a) 0x99fffL b) ABCDEFG c) 0x99fffa d) 99671246

a

Which data type value is returned by all transcendental math functions? a) int b) float c) double d) long

c

What is the output of this program? 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.5656 b) 301 c) 301.56 d) 301.56560000

a

What is the output of this program? class array_output { public static void main(String args[]) { int array_variable [] = new int[10]; for (int i = 0; i < 10; ++i) { array_variable[i] = i; System.out.print(array_variable[i] + " "); i++; } } } a) 0 2 4 6 8 b) 1 3 5 7 9 c) 0 1 2 3 4 5 6 7 8 9 d) 1 2 3 4 5 6 7 8 9 10

a

What is the output of this 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 i b) 0 1 2 3 4 c) i j k l m d) None of the mentioned

a

What is the output of this program? class dynamic_initialization { public static void main(String args[]) { double a, b; a = 3.0; b = 4.0; double c = Math.sqrt(a * a + b * b); System.out.println(c); } } a) 5.0 b) 25.0 c) 7.0 d) Compilation Error

a

What is the output of this program? class array_output { public static void main(String args[]) { int array_variable [] = new int[10]; for (int i = 0; i < 10; ++i) { array_variable[i] = i/2; array_variable[i]++; System.out.print(array_variable[i] + " "); i++; } } } a) 0 2 4 6 8 b) 1 2 3 4 5 c) 0 1 2 3 4 5 6 7 8 9 d) 1 2 3 4 5 6 7 8 9 10

b

What is the output of this program? class array_output { public static void main(String args[]) { int array_variable[][] = {{ 1, 2, 3}, { 4 , 5, 6}, { 7, 8, 9}}; int sum = 0; for (int i = 0; i < 3; ++i) for (int j = 0; j < 3 ; ++j) sum = sum + array_variable[i][j]; System.out.print(sum / 5); } } a) 8 b) 9 c) 10 d) 11

b

What is the output of this program? class asciicodes { public static void main(String args[]) { char var1 = 'A'; char var2 = 'a'; System.out.println((int)var1 + " " + (int)var2); } } a) 162 b) 65 97 c) 67 95 d) 66 98

b

What is the output of this program? class multidimention_array { public static void main(String args[]) { int arr[][] = new int[3][]; arr[0] = new int[1]; arr[1] = new int[2]; arr[2] = new int[3]; int sum = 0; for (int i = 0; i < 3; ++i) for (int j = 0; j < i + 1; ++j) arr[i][j] = j + 1; for (int i = 0; i < 3; ++i) for (int j = 0; j < i + 1; ++j) sum + = arr[i][j]; System.out.print(sum); } } a) 11 b) 10 c) 13 d) 14

b

Which of these literals can be contained in a data type float variable? a) 1.7e-308 b) 3.4e-038 c) 1.7e+308 d) 3.4e-050

b

What is the output of this program? class evaluate { public static void main(String args[]) { int a[] = {1,2,3,4,5}; int d[] = a; int sum = 0; for (int j = 0; j < 3; ++j) sum += (a[j] * d[j + 1]) + (a[j + 1] * d[j]); System.out.println(sum); } } a) 38 b) 39 c) 40 d) 41

c

What is the output of this program? class evaluate { public static void main(String args[]) { int arr[] = new int[] {0 , 1, 2, 3, 4, 5, 6, 7, 8, 9}; int n = 6; n = arr[arr[n] / 2]; System.out.println(arr[n] / 2); } } a) 3 b) 0 c) 6 d) 1

d

What is the output of this program? class variable_scope { public static void main(String args[]) { int x; x = 5; { int y = 6; System.out.print(x + " " + y); } System.out.println(x + " " + y); } } a) 5 6 5 6 b) 5 6 5 c) Runtime error d) Compilation error

d

What will this code print? int arr[] = new int [5]; System.out.print(arr); a) 0 b) value stored in arr[0]. c) 00000 d) Garbage value

d

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 2 b) 2 and 3 c) 3 and 4 d) All statements are correct.

d

Which of these is an incorrect array declaration? a) int arr[] = new int[5] b) int [] arr = new int[5] c) int arr[] arr = new int[5] d) int arr[] = int [5] new

d

Which of these is incorrect string literal? a) "Hello World" b) "Hello\nWorld" c) "\"Hello World"" d) "Hello world"

d

Which of these occupy first 0 to 127 in Unicode character set used for characters in Java? a) ASCII b) ISO-LATIN-1 c) None of the mentioned d) ASCII and ISO-LATIN1

d


Conjuntos de estudio relacionados

8, 9, 10 and 11 test business management

View Set

BIO110 - Module 3 Homework Study Guide

View Set

Health Assessment - Midterm Exam

View Set

Construction Management: Jumpstart Ch 5-12

View Set

Prerequisites for Azure administrators

View Set

Beacon - Fundamentals of SOC (Security Operations Center) Assessment (02/10/20)

View Set

Coordinator/Manager of Care / Exam 5 / NUR 112

View Set

Developmental Psychopathology test 1

View Set