click below
click below
Normal Size Small Size show me how
JAVA 3 and 4
| Question | Answer |
|---|---|
| float f = 42.0f; float[] f1 = new float[2]; float[] f2 = new float[2]; float[] f3 = f1; long x = 42; f1[0] = 42.0f; Which are true Option 1. f1 == f2 Option 2. f1 == f3 Option 3. f2 == f1[1] Option 4. x == f1[0] Option 5. f == f1[0] | 2, f1 == f3 4, x == f1[0] 5, f == f1[0] |
| int dailywage = 4; int number_of_days = 5; int salary = number_of_days++ * --dailywage * dailywage++ * number_of_days--; salary =- dailywage; System.out.println(dailywage + " " + number_of_days + " " + salary); | 4 5 266 |
| The for loop executes a given statement or block of statements repeatedly as long as the value of the expression is true. | false |
| What does the code output? int p=0; while (p<3) { p++; System.out.println(p); } | 1 2 3 |
| int a[] = {2}; a = new int[]{5}; int x = a[0]; while (x >= 0) { process(a); x = a[0]; x--; System.out.println("x = " + x); } private static void process(int[] a) { int x = a[0]--; x++; } | x = 3 x = 2 x = 1 x = 0 x = -1 |
| They return the result of shifting the bits of the left operand by the number of positions specified by the right operand. | shift operator |
| Which of the following declares an array of integers named number? | int [ ] number ; |
| What is the Enhanced for Loop (foreach)? | It transverses all elements of a collection. |
| It consists of three operands and is used to evaluate Boolean expressions | Ternary operator |
| arithmetic operator is a mathematical function that takes two operands and performs a calculation on them. | true |
| if (true) { int[] str = {5}; String i = "" + str[0]; System.out.print(i); } System.out.print("-"); { int[] str = {1, 2}; System.out.print(str[1]);}System.out.print("-");{ String str = "I like Java Programming Language"; System.out.print(str);} System. | 5-2-I like Java Programming Language-124 |
| What is the result of -7%2 | -1 |
| { int marks[] = new int[4]; marks = new int[] {87, 76, 84, 57}; for(int i = 0; i < 4; i++) { System.out.println(marks[i]);} { int marks[] = new int[4]; marks = new int[{87, 76, 84, 57}]; for(int i = 0; i < 4; i++) { System.out.println(marks[i]) | ArrayOutput2 does not compile, but ArrayOutput1 will compile |
| 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 |
| bitwise operator is an operator used to perform bitwise operations on bit patterns or binary numerals that involve the manipulation of individual bits | true |
| Consider the following codes: int x=2; System.out.println(++x); What will be the EXACT output? | 3 |
| 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 |
| boolean lampX = false, result; boolean 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 true Lamp switch-on true |
| What will be the output of the following program? int a = 0152; a *= --a / 2 * 2; System.out.println("a=" + a); | a=11024 |
| For which of the following applications is an array NOT suitable: | Holding the name, social security number, age, and income of one individual. |