click below
click below
Normal Size Small Size show me how
CCS0070 M3 - M4
| Question | Answer |
|---|---|
| Consider the following codes: int x=3; System.out.println(--x); What will be the EXACT output? | 2 |
| What will be the output of the following program? boolean a = true; boolean b = false; System.out.println(" a | b = " + (a | b)); System.out.println(" a & b = " + (a & b)); | a | b = true a & b = false |
| What will be the output of the following program? boolean a = true; boolean b = false; System.out.println(" a ^ b = " + (a ^ b)); System.out.println(" a ^ !b = " + (a ^ !b)); | a ^ b = true a ^ !b = false |
| What will be the output of the following program? boolean a = true; boolean b = false; System.out.println(" !a && b = " + (!a && b)); System.out.println(" !a || !b = " + (!a || !b)); | !a && b = false !a || !b = true |
| The ______ loop executes a given statement or a block of statements for a definite number of times. | for |
| [ T / F ]The lbl identifies any valid statement to which control must be transferred | False |
| What does the code output? int x=3; int i=0; while(i<3){ System.out.println("hi"); i++; } | hi hi hi |
| Consider the following codes: int x=3; System.out.println(++x); What will be the EXACT output? | 4 |
| [ T / F ]The else statement performs a different set of statements if the expression is false. | True |
| [ T / F ] The statements associated with else keyword is executed if the value of the switch variable does not match any of the case constants. | True |
| What will be the output of the following program? int i = 34.0; int j = 7; int k = i % j; System.out.println("k = " + k ); | the program will encounter a error |
| It adds right operand to the left operand and assign the result to left operand. | += |
| Supposed: double x = 13.1614; int y = (int)x; what is the value of y? | 13 |
| [ T / F ] The for loop facilitates evaluation of condition or expression at the end of the loop to ensure that the statements are executed at least once | False |
| How many objects are present after the following code fragment has executed? double[] ann = new double[ 7 ]; double[] bob; bob = ann; | 1 There is only one array object in memory, and both ann and bob refer to it. No new object is created in the assignment bob = ann. |
| [ T / F ] 10>15 || 2<3||100<23 | True |
| The ________ identifies any valid statement to which control must be transferred Marker Pointer Label Reference | Label |
| Consider the following codes: int x=1; System.out.println(x++); What will be the EXACT output? | 1 |
| Used to reverse the logical state of its operand. | ! & | ! |
| is an operator used to perform bitwise operations on bit patterns or binary numerals that involve the manipulation of individual bits Arithmetic Operator Relational Operator Bitwise Operator Logical Operator | bitwise operator |
| What is the output of the following code fragment? for ( int j = 10; j > 5; j-- ) System.out.print( j + " " ); System.out.println( ); | 10 9 8 7 6 |
| The statements associated with this keyword is executed if the value of the switch variable does not match any of the case constants. | default |
| [ T / F ] The case statement is used to conditionally perform statements based on an integer expression | True |
| What will be the output of the following program System.out.println(10 * 5 + 100 * (25 * 11) / (25 * 10) * 10 - 5 + 7% 2); int zx = (10 * 5 + 100 * (25 * 11)); int yz = ((25 * 10) * 10 - 5 + 7 % 2); System.out.println(zx / yz); | 1146 11 |
| [ T / F ] arithmetic operator is a mathematical function that takes two operands and performs a calculation on them. | True |
| [ T / F ] The while loop executes a given statement or block of statements repeatedly as long as the value of the expression is true. | True |
| Consider the following codes: int x=4; System.out.println(--x); What will be the EXACT output? | 3 |
| What is the output of the following code fragment: int[] ar = {2, 4, 6, 8 }; ar[0] = 23; ar[3] = ar[1]; System.out.println( ar[0] + " " + ar[3] ); | 23 4 |
| What does a Two-Dimensional Array do? Choices: It forms a tabular, two dimensional arrangement. It creates two arrays at once. It creates an array with only two elements. None of the Choices | It forms a tabular, two dimensional arrangement. |
| What will be the output of the following program? int c = 0, e = 50; boolean b = (c == 1) && (++e < 100); System.out.println("e = " + e); boolean f = (++e < 100) && (c == 1); System.out.println("e = " + e); | e = 50 e = 51 |
| If both the operands are non-zero, then the condition becomes true. | && |
| It is a mathematical function that takes two operands and performs a calculation on them. | arithmetic operator |
| Consider the following codes: int x=3; System.out.println(++x); What will be the EXACT output? | 4 |
| [ T / F ] Conditional operator is also known as the ternary operator that accepts three operands | True |
| An operator that shifts bits to the left or right shift. | shift operator |
| An operator that copies a bit if it exists in either operand. | | (bitwise OR) |
| Checks if the values of two operands are equal or not, if values are not equal then condition becomes true. | != |
| The _______ statement causes the program flow to exit from the body of the switch construct | break |
| What is the result of 7%2 | 1 |
| [ T / F ] The lbl identifies any valid statement to which control must be transferred | False |
| What will be the output of the following program? int x = 42; double y = 42.25; System.out.println("x mod 10 = " + x % 10 ); System.out.println("y mod 10 = " + y % 10 ); | x mod 10 = 2 y mod 10 = 2.25 |
| What is the output of the following code fragment int count = 0; for ( ; count < 9; ++count ) System.out.print( count + " " ); System.out.println( ); | 0 1 2 3 4 5 6 7 8 |
| Consider the following codes: int x=2; System.out.println(x--); What will be the EXACT output? | 2 |
| What is the result of 7|2 | 7 0111 (7) | 0010 (2) -------- 0111 (result) |
| An operator that can be used to add String objects. + - * / | + |
| Consider the following codes: int x=3; System.out.println(x++); What will be the EXACT output? | 3 |
| It adds right operand to the left operand and assign the result to left operand. += -+ *= | += |
| What will be the output of the following program? bool lampX = false, result; bool lampY = true; result = lampY && lampX; System.out.println("Lamp switch-on " + result); result = lampY & lampX; System.out.println("Lamp switch-on " + result); | Lamp switch-on false Lamp switch-on false |
| Consider the following codes: int x=2; System.out.println(--x); What will be the EXACT output? | 1 |
| [ T / F ] The case statement is used to conditionally perform statements based on an integer expression | True |
| Checks if the values of two operands are equal or not, if yes then condition becomes true. += == -= | == |
| [ T / F ] shift operators decrease the value of the variable by a particular number by which it was decreased | False |
| [ T / F ] 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 |
| [ T / F ] The statements associated with default keyword is executed if the value of the switch variable does not match any of the case constants. | True |
| [ T / F ] The for loop facilitates evaluation of condition or expression at the end of the loop to ensure that the statements are executed at least once | False |
| [ T / F ] bitwise operator is an operator that takes only one value for its operation | False |
| What is the result of 7&2 | 2 0111 (7) & 0010 (2) -------- 0010 (result) |
| [ T / F ] The continue 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. | True |
| [ T / F ] Decrement operators increase the value of the variable by a particular number by which it is increased | False |
| Consider the following codes: int x=4; System.out.println(--x); What will be the EXACT output? | 3 |
| It multiplies right operand with the left operand and assign the result to left operand. += -= *= | *= |
| It adds right operand to the left operand and assign the result to left operand. += -= *= | += |
| The _____ statement performs a different set of statements if the expression is false. else if case | else |
| An operator that can be used to add String objects. + - * | + |
| [ T / F ] The foreach loop is for traversing items in a collection | True |
| It subtracts right operand from the left operand and assign the result to left operand. += -= *= | -= |
| [ T / F ] The else statement performs a different set of statements if the expression is false. | True |
| What will be the output of the following program? int a = 10; int b = a - 5; System.out.println(a <= b); System.out.println(a > b); | false true |
| [ T / F ] arithmetic operator is a mathematical function that takes two operands and performs a calculation on them. | True |
| [ T / F ] The continue statement causes the program flow to exit from the body of the switch construct. | False |
| [ T / F ] The while loop executes a given statement or block of statements repeatedly as long as the value of the expression is true. | True |
| Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true. < > >= <= | < |
| Consider the following codes: int x=4; System.out.println(x--); What will be the EXACT output? | 4 |
| [ T / F ] shift operators decrease the value of the variable by a particular number by which it was decreased | False |
| What is the correct order of operations in Java? Parenthesis, (Mul/Div/Mod), (Add/Sub) (Add/Sub), (Mul/Div/Mod), Parenthesis (Mul/Div/Mod), (Add/Sub), Parenthesis (Add/Sub), Parenthesis, (Mul/Div/Mod) | Parenthesis, (Mul/Div/Mod), (Add/Sub) |