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 [...]
Ensurepass  QUESTION 91 Given:   public class ColorTest {   public static void main(String[] args) {   String[] colors = {"red", "blue","green","yellow","maroon","cyan"};   int count = 0;   for (String c : colors) {   if (count >= 4) {   break;   }   else {   continue;   }   if (c.length() >= 4) {   colors[count] = c.substring(0,3);   }   count++;   }   System.out.println(colors[count]);   }   Read more [...]
Ensurepass  QUESTION 21 Given:   import java.util.*;   public class Ref {   public static void main(String[] args) {   StringBuilder s1 = new StringBuilder("Hello Java!");   String s2 = s1.toString();   List<String> lst = new ArrayList<String>();   lst.add(s2);   System.out.println(s1.getClass());   System.out.println(s2.getClass());   System.out.println(lst.getClass());   }   }   What is the result?   A. Read more [...]
Ensurepass  QUESTION 31 Given:     Which three lines will compile and output "right on!"?   A. Line 5 B. Line 6 C. Line 7 D. Line 8 E. Line 9 F. Line 10   Correct Answer: CDF     QUESTION 32 Given:     What is the result?   A. null B. compilation fails C. Java.lang.NullPointerException D. 0   Correct Answer: C Explanation: An array variable (here xx) can very well have the null value.   Note: Null is the Read more [...]
EnsurepassQUESTION 1 Which code fragment cause a compilation error?   A. flat flt = 100F; B. float flt = (float) 1_11.00; C. float flt = 100; D. double y1 = 203.22; floatflt = y1 E. int y2 = 100; floatflt = (float) y2;   < font face="Arial">Correct Answer: B     QUESTION 2 Given the code format:     Which code fragment must be inserted at line 6 to enable the code to compile?   A. DBConfiguration f; return f; B. Return DBConfiguration; Read more [...]