click below
click below
Normal Size Small Size show me how
OOP [F2]
Object Oriented Programming Formative 2
| Question | Answer |
|---|---|
| The _____ statement causes the program flow to exit prematurely from the body of the loop statement. continue break else else if | break |
| The ______ loop executes a given statement or block of statements repeatedly as long as the value of the expression is true. while for switch case | while |
| The break statement causes the program flow to skip over and jump to the end of the loop body, and then return the control to the loop control statement. false true | false |
| arithmetic operator is a mathematical function that takes two operands and performs a calculation on them. false true | true |
| It divides left operand with the right operand and assign the result to left operand. -= *- += /= | /= |
| unary operator is an operator used to perform bitwise operations on bit patterns or binary numerals that involve the manipulation of individual bits true false | false |
| It subtracts right operand from the left operand and assign the result to left operand. += *- -= /= | -= |
| The ________ identifies any valid statement to which control must be transferred break label continue lbl | label |
| What does a Two-Dimensional Array do? It forms a tabular, two dimensional arrangement. None of the choices It creates an array with only two elements. It creates two arrays at once. | It forms a tabular, two dimensional arrangement. |
| They return the result of shifting the bits of the left operand by the number of positions specified by the right operand. arithmetic operator bitwise operator shift operator unary operator | shift operator |
| What is the output of the following code fragment: int[] z = new int[9]; z[0] = 7; z[1] = 3; z[2] = 4; System.out.println( z[0] + z[1] + " " + z[5] ); 73 0 The program is defective and will not compile. 7 3 4 10 0 | 10 0 |
| An operator that is used in converting one type into another type or an object into another Cast Assignment Relational Logical | Cast |
| What will be the output of the following program? int i, j, k, l = 0; k = l++; j = ++k; i = j++; System.out.println(i); 0 2 5 1 | 1 |
| The continue statement causes the program flow to exit from the body of the switch construct. true false | false |
| The statements associated with this keyword is executed if the value of the switch variable does not match any of the case constants. else default last option | default |
| An operator that divides left-hand operand by right-hand operand. + * / - | / |
| Consider the following codes: int x=1; System.out.println(++x); What will be the EXACT output? 4 1 2 3 | 2 |
| Consider the following codes: int x=4; System.out.println(x--); What will be the EXACT output? 4 3 2 1 | 4 |
| The ______ loop executes a given statement or a block of statements for a definite number of times. do while while for | for |
| What is the output of the following code fragment: int[] ar = {2, 4, 6, 8 }; System.out.println( ar[0] + " " + ar[1] ); 2 6 8 6 8 2 4 | 2 4 |
| They return the result of shifting the bits of the left operand by the number of positions specified by the right operand. bitwise operator arithmetic operator shift operator unary operator | shift operator |
| Consider the following codes: int x=3; System.out.println(x--); What will be the EXACT output? 2 4 1 3 | 3 |
| An operator that decreases the value of operand by 1. 1- -1 -- ā | -- |
| Checks if the values of two operands are equal or not, if yes then condition becomes true. = == != ! | == |
| What is the EXACT output: int i = 4; int j = 21; int k = ++i * 7 + 2 - j--; System.out.println("k = " + k); k = 17 k = 11 k = 16 Program does not compile | k = 16 |
| How many objects are present after the following code fragment has executed? double[] ann = new double[ 7 ]; double[] bob; bob = ann; 7 2 14 1 | 1 |
| The for loop is for traversing items in a collection false true | false |
| Consider the following codes: int x=3; System.out.println(++x); What will be the EXACT output? 2 4 3 1 | 4 |
| increase the value of the variable by a particular number by which it is increased Increment operators Decrement operators | Increment operators |
| The do-while loop facilitates evaluation of condition or expression at the end of the loop to ensure that the statements are executed at least once false true | true |
| Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true. >> > < < | > |
| The _____ statement performs a different set of statements if the expression is false. else if | else |
| Decrement operators increase the value of the variable by a particular number by which it is increased true false | false |
| An operator that subtracts right-hand operand from left-hand operand. Group of answer choices - / + * | - |
| When a piece of code runs unintentionally forever it is known as A broken loop An infinite loop A for loop A long loop | An infinite loop |
| It consists of three operands and is used to evaluate Boolean expressions Assignment operator Ternary operator Logical Operator Cast Operator | Ternary operator |
| The foreach loop is for traversing items in a collection true false | true |
| What must the change be so that the following fragment prints out the even integers 0 2 4 6 8 10? for ( int j = 0; j <= 10; _______ ) System.out.print( j + " " ); System.out.println( ); ++j++ j++++ j+2 j = j+2 | j = j+2 |
| Dividing integer by zero results in the throwing of ____________ ComputeException DivideByZeroException MathError ArithmeticException | ArithmeticException |
| An operator that copies a bit to the result if it exists in both operands. ~ (bitwise compliment) | (bitwise OR) ^ (bitwise XOR) & (bitwise AND) | & (bitwise AND) |
| It is a mathematical function that takes two operands and performs a calculation on them. bitwise operator unary operator shift operator arithmetic operator | arithmetic operator |
| The _____ loop is for traversing items in a collection do while foreach for while | foreach |
| What is the result of 7%2 4 3 2 1 | 1 |
| Which is first incremented and then used? +x x+ ++x x++ | ++x |
| The ______ statement causes the program flow to skip over and jump to the end of the loop body, and then return the control to the loop control statement. break else else if continue | continue |
| What is an array? A program that you can use to execute another program and analyze its run-time behavior May contains elements with different data types. A random integer A sequence of values. | A sequence of values. |
| What is the result of -7%2 -1 1 2 -2 | -1 |
| What is the result of 7|2 10 8 9 7 | 7 |
| shift operator is a mathematical function that takes two operands and performs a calculation on them. false true | false |
| What is the result of ~1 -2 1 2 -1 | -2 |
| Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true. >> <= < >= | >= |
| The lbl identifies any valid statement to which control must be transferred true false | false |
| What will be the output of the following program? int a = 4; a++; a += a; --a; a = 7 + a; a *= a; a -= 3; System.out.println(" a = " + a ); Program does not compile a = 286 a = 255 a = 253 | a = 253 |