Q1. Given the code fragment: What is the result? A. 2 2 B. 1 2 C. 3 2 D. 3 3 View AnswerAnswer: A Q2. What is the result? A. Initialized Started B. Initialized Started Initialized C. Compilation fails D. An exception is thrown at runtime View AnswerAnswer: B Q3. Which two statements are true for a two-dimensional array? A. It is implemented as an array of the specified element type. B. Using a row by column convention,…
Q1. Given: What is the result? A. 11, 21, 31, 11, 21, 31 B. 11, 21, 31, 12, 22, 32 C. 12, 22, 32, 12, 22, 32 D. 10, 20, 30, 10, 20, 30 View AnswerAnswer: D Q2. Given: What is the result? A. true true B. true false C. false true D. false false E. Compilation fails View AnswerAnswer: E Q3. What is the result? A. Hello B. Default C. Compilation fails D. The program prints nothing E. An…
Q1. Given: A. Good Day! Good Luck! B. Good Day! Good Day! C. Good Luck! Good Day! D. Good Luck! Good Luck! E. Compilation fails View AnswerAnswer: E Q2. 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; C. Return new DBConfiguration; D. Retutn 0; View AnswerAnswer: B Q3. Given: And the commands: Javac Test.java Java Test 12345 What is the result? A. Number us…
Q1. Given a code fragment: A. They match They real match B. They really match C. They match D. Nothing is printed to the screen View AnswerAnswer: B Q2. Given: What is the result? A. One B. Two C. Three D. Compilation fails View AnswerAnswer: C Q3. View the exhibit: public class Student { public String name = ""; public int age = 0; public String major = "Undeclared"; public boolean fulltime = true; public void display() { System.out.println("Name: "…
Q1. Given: Class A { } Class B { } Interface X { } Interface Y { } Which two definitions of class C are valid? A. Class C extends A implements X { } B. Class C implements Y extends B { } C. Class C extends A, B { } D. Class C implements X, Y extends B { } E. Class C extends B implements X, Y…
Q1. int [] array = {1,2,3,4,5}; for (int i: array) { if ( i < 2) { keyword1 ; } System.out.println(i); if ( i == 3) { keyword2 ; }} What should keyword1 and keyword2 be respectively, in oreder to produce output 2345? A. continue, break B. break, break C. break, continue D. continue, continue View AnswerAnswer: D Q2. Given: What is the result? A. null B. compilation fails C. Java.lang.NullPointerException D. 0 View AnswerAnswer: A Q3. Given the code fragment: What is…
Q1. Class StaticField { static int i = 7; public static void main(String[] args) { StaticFied obj = new StaticField(); obj.i++; StaticField.i++; obj.i++; System.out.println(StaticField.i + " "+ obj.i); } } What is the result? A. 10 10 B. 8 9 C. 9 8 D. 7 10 View AnswerAnswer: A Q2. Given the code fragment: What is the result? A. 2 2 B. 1 2 C. 3 2 D. 3 3 View AnswerAnswer: A Q3. which three lines are illegal? A. line 3 B. line 4 C.…
Q1. What is the result? A. Valid B. Not valid C. Compilation fails D. An IllegalArgumentException is thrown at run time View AnswerAnswer: C Q2. Given the code fragment: int b = 3; Oracle 1z0-803 : Practice Test 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. View AnswerAnswer: C Q3. Int [] [] array = {{0}, {0, 1}, {0, 2, 4}, {0, 3,…
Q1. Given: public class Main { public static void main(String[] args) { try { doSomething(); } catch (SpecialException e) { System.out.println(e); }} static void doSomething() { int [] ages = new int[4]; ages[4] = 17; doSomethingElse(); } static void doSomethingElse() { throw new SpecialException("Thrown at end of doSomething() method"); } } What is the output? A. SpecialException: Thrown at end of doSomething() method B. Error in thread "main" java.lang. ArrayIndexOutOfBoundseror C. Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4 at Main.doSomething(Main.java:12) at Main.main(Main.java:4) D. SpecialException: Thrown…
Q1. Given: What is the result? A. 1 1 1 B. 1 2 3 C. 2 3 4 D. Compilation fails E. The loop executes infinite times View AnswerAnswer: D Q2. Given: What is the result? A. The sum is 2 B. The sum is 14 C. The sum is 15 D. The loop executes infinite times E. Compilation fails View AnswerAnswer: D Q3. Given: What is the result? A. true true B. true false C. false true D. false false E.…
Q1. Which two packages are automatically imported into the java source file by the java compiler? A. Java.lang B. Java.awt C. Java.util D. Javax.net E. Java.* F. The package with no name View AnswerAnswer: AF Q2. Given: What is the result? A. 6 5 6 4 B. 6 5 5 4 C. 6 5 6 6 D. 6 5 6 5 View AnswerAnswer: A Q3. Given: What is the result? A. null B. compilation fails C. Java.lang.NullPointerException D. 0 View AnswerAnswer:…
Q1. Given: What is the result? A. x: 1 y: 2 B. 3 y: 4 C. x: 0 y: 0 D. 3 y: 4 E. x: 1 y: 2 F. 0 y: 0 G. x: 0 y: 0 H. 0 y: 0 View AnswerAnswer: C Q2. Which two actions will improve the encapsulation of a class? A. Changing the access modifier of a field from public to private B. Removing the public modifier…
Q1. Given: Which code fragment, when inserted at line 7, enables the code print true? A. Option A B. Option B C. Option C D. Option D View AnswerAnswer: A Q2. Given: What should statement1, statement2, and statement3, be respectively, in order to produce the result? Shape: constructor Square: foo Shape: foo A. Option A B. Option B C. Option C D. Option D E. Option E View AnswerAnswer: D Q3. Given: What is the result? A. 0 B. 0 1…
Q1. Given: What is the result? A. 2 4 6 8 B. 2 4 6 8 9 C. 1 3 5 7 D. 1 3 5 7 9 View AnswerAnswer: DQ2. Given the code fragment: System.out.printIn("Result: " + 2 + 3 + 5); System.out.printIn("Result: " + 2 + 3 * 5); What is the result? A. Result: 10 Result: 30 Result: 10 Result: 25 C. Result: 235 Result: 215 D. Result: 215 Result: 215 E. Compilation fails View AnswerAnswer:…
Q1. public class StringReplace { public static void main(String[] args) { String message = "Hi everyone!"; System.out.println("message = " + message.replace("e", "X")); } } What is the result? A. message = Hi everyone! B. message = Hi XvXryonX! C. A compile time error is produced. D. A runtime error is produced. E. message = F. message = Hi Xveryone! View AnswerAnswer: B Q2. You are writing a method that is declared not to…
Q1. Given: Which code fragment, when inserted at line 14, enables the code to print Mike Found? A. int f = ps.indexOf {new patient (“Mike”)}; B. int f = ps.indexOf (patient(“Mike”)); C. patient p = new Patient (“Mike”); int f = pas.indexOf(P) D. int f = ps.indexOf(p2); View AnswerAnswer: C Q2. Which code fragment cause a compilation error? A. flat flt = 100F; B. float flt = (float) 1_11.00; C. float…
Q1. for ( expr1 ; expr2 ; expr3 ) { statement; } Which two statements are true? A. This is not the only valid for loop construct; there exits another form of for loop constructor. B. The expression expr1 is optional. it initializes the loop and is evaluated once, as the loop begin. C. When expr2 evaluates to false, the loop terminates. It is evaluated only after each iteration…
Q1. Given: What three modifications, made independently, made to class greet, enable the code to compile and run? A. line 6 replaced with handy.dandy.keystroke stroke = new KeyStroke ( ); B. line 6 replaced with handy.*.KeyStroke = new KeyStroke ( ); C. line 6 replaced with handy.dandy.KeyStroke Stroke = new handy.dandy.KeyStroke(); D. import handy.*; added before line 1 E. import handy.dandy.*; added after line 1 F. import…
Q1. int [] array = {1,2,3,4,5}; for (int i: array) { if ( i < 2) { keyword1 ; } System.out.println(i); if ( i == 3) { keyword2 ; }} What should keyword1 and keyword2 be respectively, in oreder to produce output 2345? A. continue, break B. break, break C. break, continue D. continue, continue View AnswerAnswer: D Q2. Given the class definitions: And the code fragment of the main() method, What is the result? A. Java Java Java B. Java Jeve va C.…
Q1. Given: Given the code fragment: What is the result? A. 10 20 30 40 B. 0 0 30 40 C. Compilation fails D. An exception is thrown at runtime View AnswerAnswer: A Q2. View the exhibit: public class Student { public String name = ""; public int age = 0; public String major = "Undeclared"; public boolean fulltime = true; public void display() { System.out.println("Name: " + name + " Major: " +…
Q1. Given the code fragment: String h1 = "Bob"; String h2 = new String ("Bob"); What is the best way to test that the values of h1 and h2 are the same? A. if (h1 = = h2) B. if (h1.equals(h2)) C. if (h1 = = h2) D. if (h1.same(h2)) View AnswerAnswer: B Q2. Given: What is the result? A. The program prints nothing B. d C. A S StringIndexOutOfBoundsException is thrown at…