PRO192.part2

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

c

If an expression contains double, int, float, long, then whole expression will promoted into which of these data types? a) long b) int c) double d) float

a

What is Truncation is Java? a) Floating-point value assigned to an integer type. b) Integer value assigned to floating type. c) Floating-point value assigned to an Floating type. d) Integer value assigned to floating type.

b

What is the error in this code? byte b = 50; b = b * 50; a) b can not contain value 100, limited by its range. b) * operator has converted b * 50 into int, which can not be converted to byte without casting. c) b can not contain value 50. d) No error in this code

d

What is the output of this program, if we run as "java main_arguments 1 2 3"? class main_arguments { public static void main(String [] args) { String [][] argument = new String[2][2]; int x; argument[0] = args; x = argument[0].length; for (int y = 0; y < x; y++) System.out.print(" " + argument[0][y]); } } a) 1 1 b) 1 0 c) 1 0 3 d) 1 2 3

c

What is the output of this program? class A { final public int calculate(int a, int b) { return 1; } } class B extends A { public int calculate(int a, int b) { return 2; } } public class output { public static void main(String args[]) { B object = new B(); System.out.print("b is " + b.calculate(0, 1)); } } a) b is : 2 b) b is : 1 c) Compilation Error. d) An exception is thrown at runtime.

d

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

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

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

d

What is the output of this program? class c { public void main( String[] args ) { System.out.println( "Hello" + args[0] ); } } a) Hello c b) Hello c) Hello world d) Runtime Error.

a

What is the output of this program? class char_increment { public static void main(String args[]) { char c1 = 'D'; char c2 = 84; c2++; c1++; System.out.println(c1 + " " + c2); } } a) E U b) U E c) V E d) U F

b

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

d

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

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

d

What is the prototype of the default constructor of this class? public class prototype { } a) prototype( ) b) prototype(void) c) public prototype(void) d) public prototype( )

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) Class name@ hashcode in hexadecimal form

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

d

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

b

Which of these is necessary condition for automatic type conversion in Java? a) The destination type is smaller than source type. b) The destination type is larger than source type. c) The destination type can be larger or smaller than source type. d) None of the mentioned

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

c

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


Conjuntos de estudio relacionados

Chapter 17 QUIZ - Human Resource Management

View Set

DRUGS AFFECTING THE FEMALE REPRODUCTIVE SYSTEM

View Set

Chapter 1,2,3- Chemistry (Completion)

View Set

***HURST Review Elevate Q-Cards***

View Set

AP Psychology Unit VII Module 35

View Set

Key Pediatric Nursing Interventions

View Set

Präpositionen Lokal - Wo? Wohin? OK

View Set

ATI Nursing Care of Children Practice Test A

View Set