Ensurepass  QUESTION 131 Given the code fragment:   int b = 3;   if ( !(b > 3)) {   System.out.println("square ");   }{   System.out.println("circle ");   }   System.out.println("...");   What is the result?   A. square... B. circle... C. squarecircle... D. Compilation fails.   Correct Answer: C     QUESTION 132 Given:     What is the result?   A. box B. nbo C. bo D. nb E. An exception Read more [...]
Ensurepass  QUESTION 121 Which two are valid declarations of a two-dimensional array?   A. int [] [] array2D; B. int [2] [2] array2D; C. int array2D []; D. int [] array2D []; E. int [] [] array2D [];   Correct Answer: AD Explanation: int[][] array2D; is the standard convention to declare a 2-dimensional integer array. int[] array2D[]; works as well, but it is not recommended.     QUESTION 122 Given the code fragment:     Which code fragment prints Read more [...]
Ensurepass  QUESTION 111 Given:     Why will the code not compile?   A. A static field cannot be private. B. The getLetter method has no body. C. There is no setLetter method. D. The letter field is uninitialized. E. It contains a method named Main instead of ma.   Correct Answer: B Explanation: The getLetter() method needs a body public static int getLetter() { }; .     QUESTION 112 Given:   public class Test {   public static void main(String[] Read more [...]
Ensurepass  QUESTION 141 Give:     What value should replacekkin line x to cause jj = 5 to be output?   A. -1 B. 1 C. 5 D. 8 E. 11   Correct Answer: E Explanation: We need to get jj to 5. It is initially set to 0. So we need to go through the for loop 5 times. The for loops ends when ii > 6 and ii decreases for every loop. So we need to initially set ii to 11. We set kk to 11.     QUESTION 142 Which two may precede the word `class' in a class Read more [...]
Ensurepass      QUESTION 101 Given the code fragments:     What is the result?   A. Super Sub Sub B. Contract Contract Super C. Compilation fails at line n1 D. Compilation fails at line n2   Correct Answer: D     QUESTION 102 Given the code fragment:   for (int ii = 0; ii < 3;ii++) {   int count = 0;   for (int jj = 3; jj > 0; jj--) {   if (ii == jj) {   ++count;   break;   }   }   System.out.print(count); Read more [...]
Ensurepass  QUESTION 11 Given the code fragment:     What is the result?   A. Values are : [EE, ME] B. Values are : [EE, EE, ME] C. Values are : [EE, ME, EE] D. Values are : [SE, EE, ME, EE] E. Values are : [EE, ME, SE, EE]   Correct Answer: E     QUESTION 12 Given the code fragment:     What is the result if the integer aVar is 9?   A. 10 Hello world! B. 10 Hello universe! C. 9 Hello world! D. Compilation fails.   Read more [...]
Ensurepass  QUESTION 41 Given:     What is the reference type of myZ and what is the type of the object it references?   A. Reference type is Z; object type is Z. B. Reference type is Y; object type is Y. C. Reference type is Z; object type is Y. D. Reference type is X; object type is Z.   Correct Answer: C     QUESTION 42 Given the code fragment:   What is the result?   A. Found Red Found Default B. Found Teal C. Found Red Found Read more [...]
Ensurepass      QUESTION 51 Given a java source file:     What changes will make this code compile? (Select Two)   A. Adding the public modifier to the declaration of class x B. Adding the protected modifier to the x() constructor C. Changing the private modifier on the declaration of the one() method to protected D. Removing the Y () constructor E. Removing the private modifier from the two () method   Correct Answer: CE Explanation: Using the Read more [...]
Ensurepass  QUESTION 61 Which code fragment is illegal?     A. Option A B. Option B C. Option C D. Option D   Correct Answer: D Explanation: The abstract keyword cannot be used to declare an int variable.   The abstract keyword is used to declare a class or method to beabstract[3]. An abstract method has no implementation; all classes containing abstract methods must themselves be abstract, although not all abstract classes have abstract methods.     Read more [...]
Ensurepass  QUESTION 71 Given:   class Overloading {   int x(double d) {   System.out.println("one");   return 0;   }   String x(double d) { System.out.println("two");   return null;   }   double x(double d) {   System.out.println("three");   return 0.0;   }   public static void main(String[] args) {   new Overloading().x(4.0);   }   }   What is the result?   A. One B. Two C. Three D. Compilation Read more [...]
Ensurepass  QUESTION 81 public class Two {   public static void main(String[] args) {   try {   doStuff();   system.out.println("1");   }   catch {   system.out.println("2");   }}   public static void do Stuff() {   if (Math.random() > 0.5) throw new RunTimeException(); doMoreStuff();   System.out.println("3 ");   }   public static void doMoreStuff() {   System.out.println("4");   }   }   Which two are possible Read more [...]