1.1. 1z0-803 Java SE 7 Programmer I 2015-08-26
1.1. 1z0-803 Java SE 7 Programmer I 2015-08-26
Number: 1z0-803
Passing Score: 800
Time Limit: 120 min
File Version: 26.5
Oracle 1z0-803
Java SE 7 Programmer I
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Exam A
QUESTION 1
Given the code fragment:
A. 3 false 1
B. 2 true 3
C. 2 false 3
D. 3 true 1
E. 3 false 3
F. 2 true 1
G. 2 false 1
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
The length of the element with index 0, {0, 1, 2}, is 3. Output: 3 The element with index 1, {3, 4, 5, 6}, is of type array. Output: true The element with
index 0, {0, 1, 2} has the element with index 1: 1. Output: 1
QUESTION 2
View the exhibit:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Real 2
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result when this program is executed?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
After the statement jian = bob; the jian will reference the same object as bob.
QUESTION 3
Given the code fragment:
A. Valid
B. Not valid
C. Compilation fails
D. An IllegalArgumentException is thrown at run time
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Real 3
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
In segment 'if (valid)' valid must be of type boolean, but it is a string.
This makes the compilation fail.
QUESTION 4
Given:
A. 6
B. 6
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
C. 6
D. 6
Real 4
Oracle 1z0-803 Exam
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Within main z is assigned 6. z is printed. Output: 6 Within doStuff z is assigned 5.DoStuff2 locally sets z to 4 (but MyScope.z is set to 4), but in Dostuff z
is still 5. z is printed. Output: 5
Again z is printed within main (with local z set to 6). Output: 6 Finally MyScope.z is printed. MyScope.z has been set to 4 within doStuff2(). Output: 4
QUESTION 5
Which two are valid instantiations and initializations of a multi dimensional array?
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
Correct Answer: BD
Section: (none)
Explanation
Explanation/Reference:
Explanation:
In the Java programming language, a multidimensional array is simply an array whose components are themselves arrays.
Real 5
Oracle 1z0-803 Exam
QUESTION 6
An unchecked exception occurs in a method dosomething()
Should other code be added in the dosomething() method for it to compile and execute?
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Because the Java programming language does not require methods to catch or to specify unchecked exceptions (RuntimeException, Error, and their
subclasses), programmers may be tempted to write code that throws only unchecked exceptions or to make all their exception subclasses inherit from
RuntimeException. Both of these shortcuts allow programmers to write code without bothering with compiler errors and without bothering to specify or to
catch any exceptions. Although this may seem convenient to the programmer, it sidesteps the intent of the catch or specify requirement and can cause
problems for others using your classes.
QUESTION 7
Given the code fragment:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result?
A. 2
B. 1
Real 6
Oracle 1z0-803 Exam
C. 3
D. 3
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Variable b is set to 4.
Variable b is decreased to 3.
Variable b is decreased to 2 and then printed. Output: 2 Variable b is printed. Output: 2
QUESTION 8
Given the code fragment:
interface SampleClosable {
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Real 7
Oracle 1z0-803 Exam
A. Option A
B. Option B
C. Option C
D. Option D
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
E. Option E
Explanation/Reference:
Explanation:
A: Throwing the same exception is fine.
C: Using a subclass of java.io.IOException (here java.io.FileNotFoundException) is fine
E: Not using a throw clause is fine.
QUESTION 9
Given the code fragment:
Int [] [] array = {{0}, {0, 1}, {0, 2, 4}, {0, 3, 6, 9}, {0, 4, 8, 12, 16}};
A. 4
Null
B. Null
C. An IllegalArgumentException is thrown at run time
D. 4
An ArrayIndexOutOfBoundException is thrown at run time
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
The first println statement, System.out.println(array [4][1]);, works fine. It selects the element/array with index 4, {0, 4, 8, 12, 16}, and from this array it
selects the element with index 1, 4. Output: 4 The second println statement, System.out.println(array) [1][4]);, fails. It selects the array/element with index
1, {0, 1}, and from this array it try to select the element with index 4. This causes an exception.
Output:
Real 8
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Oracle 1z0-803 Exam
QUESTION 10
Given:
A. Zero
B. Once
C. Twice
D. Thrice
E. Compilation fails.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 11
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Real 9
Oracle 1z0-803 Exam
Which two actions, used independently, will permit this class to compile?
Correct Answer: CD
Section: (none)
Explanation
Explanation/Reference:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation:
The IOException must be caught or be declared to be thrown. We must add a throws exception to the doSomething () method signature (static void
doSomething() throws IOException).
Then we can either add the same throws IOException to the main method (public static void main (String[] args) throws IOException), or change the
catch statement in main to IOException.
QUESTION 12
Given:
Real 10
Oracle 1z0-803 Exam
What is the result?
A. Hello
B. Default
C. Compilation fails
D. The program prints nothing
E. An exception is thrown at run time
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
The program compiles fine.
The program runs fine.
The output is: hello
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
QUESTION 13
Given:
A. asc = sc;
B. sc = asc;
C. asc = (object) sc;
D. asc = sc.clone ()
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Works fine.
QUESTION 14
Given the code fragment:
Real 11
Oracle 1z0-803 Exam
System.out.printIn("Result: " + 2 + 3 + 5);
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A. Result: 10
Result: 30
B. Result: 10
Result: 25
C. Result: 235
Result: 215
D. Result: 215
Result: 215
E. Compilation fails
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
First line:
System.out.println("Result: " + 2 + 3 + 5);
String concatenation is produced.
Second line:
System.out.println("Result: " + 2 + 3 * 5);
3*5 is calculated to 15 and is appended to string 2. Result 215.
Note #1:
To produce an arithmetic result, the following code would have to be used:
System.out.println("Result: " + (2 + 3 + 5));
System.out.println("Result: " + (2 + 1 * 5));
run:
Result: 10
Result: 7
Note #2:
If the code was as follows:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Real 12
Oracle 1z0-803 Exam
The compilation would fail. There is an unclosed string literal, 5", on each line.
QUESTION 15
Which code fragment is illegal?
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: D
Section: (none)
Explanation
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation/Reference:
Explanation:
The abstract keyword cannot be used to declare an int variable.
The abstract keyword is used to declare a class or method to be abstract[3]. An abstract method has no implementation; all classes containing abstract
methods must themselves be abstract, although not all abstract classes have abstract methods.
QUESTION 16
Given the code fragment:
int a = 0;
Real 13
Oracle 1z0-803 Exam
a++;
System.out.printIn(a++);
System.out.printIn(a);
A.
B.
C.
D.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
The first println prints variable a with value 1 and then increases the variable to 2.
QUESTION 17
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result?
A. There is no output
B. d is output
C. A StringIndexOutOfBoundsException is thrown at runtime
D. An ArrayIndexOutOfBoundsException is thrown at runtime Real 14
Oracle 1z0-803 Exam
E. A NullPointException is thrown at runtime
F. A StringArrayIndexOutOfBoundsException is thrown at runtime
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
There are only 11 characters in the string "Hello World". The code theString.charAt(11) retrieves the 12th character, which does not exist. A
StringIndexOutOfBoundsException is thrown. Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range:
QUESTION 18
Given a java source file:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What changes will make this code compile? (Select Two)
Correct Answer: CE
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Using the private protected, instead of the private modifier, for the declaration of the one() method, would enable the two() method to access the one()
method.
Real 15
Oracle 1z0-803 Exam
QUESTION 19
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What three modifications, made independently, made to class greet, enable the code to compile and run?
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation/Reference:
Explanation:
Three separate solutions:
C: the full class path to the method must be stated (when we have not imported the package)
D: We can import the hold dandy class
F: we can import the specific method
QUESTION 20
Real 16
Oracle 1z0-803 Exam
Given:
A. They match
They really match
B. They really match
C. They match
D. Nothing Prints
E. They really match
They really match
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation:
The strings are not the same objects so the == comparison fails. See note #1 below. As the value of the strings are the same equals is true. The equals
method compares values for equality.
Note: #1 ==
Compares references, not values. The use of == with object references is generally limited to the following:
Comparing to see if a reference is null.
Comparing two enum values. This works because there is only one object for each enum constant.
You want to know if two references are to the same object.
QUESTION 21
Given:
Real 17
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A. Line 5
B. Line 6
C. Line 7
D. Line 8
E. Line 9
F. Line 10
Explanation/Reference:
Explanation:
QUESTION 22
Given the code fragment:
String h1 = "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))
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Real 18
Oracle 1z0-803 Exam
Explanation:
The equals method compares values for equality.
QUESTION 23
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
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
Section: (none)
Explanation
Explanation/Reference:
Explanation:
int[][] array2D; is the standard convention to declare a 2-dimensional integer array.
QUESTION 24
Given the code fragment:
A. Result: 8
Result: 8
B. Result: 35
Result: 8
C. Result: 8
Result: 35
D. Result: 35
Result: 35
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Real 19
Oracle 1z0-803 Exam
Explanation:
In the first statement 3 and 5 are treated as strings and are simply concatenated. In the first statement 3 and 5 are treated as integers and their sum is
calculated.
QUESTION 25
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: AD
Section: (none)
Explanation
Explanation/Reference:
Explanation:
The first println statement, System.out.println("Before if clause");, will always run.
Real 20
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
If Math.Random() > 0.5 then there is an exception. The exception message is displayed and the program terminates.
If Math.Random() > 0.5 is false, then the second println statement runs as well.
QUESTION 26
A method doSomething () that has no exception handling code is modified to trail a method that throws a checked exception. Which two modifications,
made independently, will allow the program to compile?
Correct Answer: AB
Section: (none)
Explanation
Explanation/Reference:
Explanation: Valid Java programming language code must honor the Catch or Specify Requirement. This means that code that might throw certain
exceptions must be enclosed by either of the following:
* A try statement that catches the exception. The try must provide a handler for the exception, as described in Catching and Handling Exceptions.
* A method that specifies that it can throw the exception. The method must provide a throws clause that lists the exception, as described in Specifying
the Exceptions Thrown by a Method.
Code that fails to honor the Catch or Specify Requirement will not compile.
QUESTION 27
Given the code fragment:
Real 21
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result?
A. Found Red
B. Found Red
Found Blue
C. Found Red
Found Blue
Found White
D. Found Red
Found Blue
Found White
Found Default
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation: As there is no break statement after the case "Red" statement the case Blue statement will run as well.
Note: The body of a switch statement is known as a switch block. A statement in the switch block can be labeled with one or more case or default labels.
The switch statement evaluates its expression, then executes all statements that follow the matching case label.
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Each break statement terminates the enclosing switch statement. Control flow continues with the first statement following the switch block. The break
statements are necessary because without them, statements in switch blocks fall through: All statements after the matching case label are executed in
sequence, regardless of the expression of subsequent case labels, until a break statement is encountered.
Real 22
Oracle 1z0-803 Exam
QUESTION 28
Which two may precede the word `class' in a class declaration?
A. local
B. public
C. static
D. volatile
E. synchronized
Correct Answer: BC
Section: (none)
Explanation
Explanation/Reference:
Explanation:
B: A class can be declared as public or private.
C: You can declare two kinds of classes: top-level classes and inner classes. You define an inner class within a top-level class. Depending on how it is
defined, an inner class can be one of the following four types: Anonymous, Local, Member and Nested top-level. A nested top-level class is a member
classes with a static modifier. A nested top-level class is just like any other top-level class except that it is declared within another class or interface.
Nested top-level classes are typically used as a convenient way to group related classes without creating a new package.
The following is an example:
QUESTION 29
Which three are bad practices?
A. Checking for ArrayIndexoutofBoundsException when iterating through an array to determine when all elements have been visited
B. Checking for Error and. If necessary, restarting the program to ensure that users are unaware problems
C. Checking for FileNotFoundException to inform a user that a filename entered is not valid
D. Checking for ArrayIndexoutofBoundsException and ensuring that the program can recover if one occur
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
E. Checking for an IOException and ensuring that the program can recover if one occurs
Explanation/Reference:
Explanation:
Real 23
Oracle 1z0-803 Exam
QUESTION 30
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
F. Option F
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Real 24
Oracle 1z0-803 Exam
Dog should be an abstract class. The correct syntax for this is: abstract class Dog { Poodle should extend Dog (not implement).
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
QUESTION 31
Given:
class X {}
class Y { Y ( ) { } }
class Z { Z (int i ) { } }
A. X only
B. Y only
C. Z only
D. X and Y
E. Y and Z
F. X and Z
G. X, Y and Z
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 32
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Real 25
Oracle 1z0-803 Exam
Which two declarations will compile?
A. int a, b, c = 0;
B. int a, b, c;
C. int g, int h, int i = 0;
D. int d, e, F;
E. int k, l, m; = 0;
Correct Answer: AD
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 33
Given the code fragment:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
1234
1234
1234
----
1234
----
Real 26
Oracle 1z0-803 Exam
A. X = 4, Y = 3, Z = 2
B. X = 3, Y = 2, Z = 3
C. X = 2, Y = 3, Z = 3
D. X = 4, Y = 2, Z = 3
E. X = 2, Y = 3, Z = 4
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Z is for the innermost loop. Should print 1 2 3 4. So Z must be 4. Y is for the middle loop. Should print three lines of 1 2 3 4. So Y must be set 3. X is for
the outmost loop. Should print 2 lines of. So X should be 2.
QUESTION 34
Which statement initializes a stringBuilder to a capacity of 128?
Correct Answer: D
Section: (none)
Explanation
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation/Reference:
Explanation:
StringBuilder(int capacity)
Constructs a string builder with no characters in it and an initial capacity specified by the capacity argument.
Note: An instance of a StringBuilder is a mutable sequence of characters. The principal operations on a StringBuilder are the append and insert
methods, which are overloaded so as to accept data of any type. Each effectively converts a given datum to a string and then appends or inserts the
characters of that string to the string builder. The append method always adds these characters at the end of the builder; the insert method adds the
characters at a specified point.
QUESTION 35
Given:
Real 27
Oracle 1z0-803 Exam
A. 0
B. 0
C. 0
D. Compilation fails
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation:
table.length is 3. So the do-while loop will run 3 times with ii=0, ii=1 and ii=2. The second while statement will break the do-loop when ii = 3. Note: The
Java programming language provides a do-while statement, which can be expressed as follows:
do {
statement(s)
} while (expression);
QUESTION 36
A method is declared to take three arguments. A program calls this method and passes only two arguments. What is the result?
Real 28
Oracle 1z0-803 Exam
A. Compilation fails.
B. The third argument is given the value null.
C. The third argument is given the value void.
D. The third argument is given the value zero.
E. The third argument is given the appropriate false value for its declared type.
F. An exception occurs when the method attempts to access the third argument.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
The problem is noticed at build/compile time. At build you would receive an error message like:
required: int,int,int
found: int,int
QUESTION 37
Given the fragment:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result?
A. 14
B. 15
C. 24
D. 25
E. 34
F. 35
Correct Answer: F
Section: (none)
Explanation
Explanation/Reference:
Explanation:
The two elements 3 and 4 (starting from position with index 2) are copied into position index 1 and 2 in the same array.
After the arraycopy command the array looks like:
{1, 3, 4, 4, 5};
Real 29
Oracle 1z0-803 Exam
QUESTION 38
Given the following code fragment:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result if the integer value is 33?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation:
33 is greater than 0.
33 is not equal to 0.
the is printed.
33 is greater than 30
fox is printed
33 is greater then 10 (the two else if are skipped)
lazy is printed
finally ... is printed.
QUESTION 39
Which three are advantages of the Java exception mechanism?
A. Improves the program structure because the error handling code is separated from the normal program function
B. Provides a set of standard exceptions that covers all the possible errors
C. Improves the program structure because the programmer can choose where to handle exceptions
D. Improves the program structure because exceptions must be handled in the method in which they occurred
E. allows the creation of new exceptions that are tailored to the particular program being
Explanation/Reference:
Explanation:
A: The error handling is separated from the normal program logic.
C: You have some choice where to handle the exceptions.
E: You can create your own exceptions.
QUESTION 40
Given:
Real 31
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result?
A. null
B. compilation fails
C. Java.lang.NullPointerException
D. 0
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
An array variable (here xx) can very well have the null value.
Note:
Null is the reserved constant used in Java to represent a void reference i.e a pointer to nothing. Internally it is just a binary 0, but in the high level Java
language, it is a magic constant, quite distinct from zero, that internally could have any representation.
QUESTION 41
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Which approach ensures that the class can be compiled and run?
Real 32
Oracle 1z0-803 Exam
A. Put the throw new Exception() statement in the try block of try catch
B. Put the doSomethingElse() method in the try block of a try catch
C. Put the doSomething() method in the try block of a try catch
D. Put the doSomething() method and the doSomethingElse() method in the try block of a try catch
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
We need to catch the exception in the doSomethingElse() method.
Such as:
private static void doSomeThingElse() {
try {
throw new Exception();}
catch (Exception e)
{}
}
Note: One alternative, but not an option here, is the declare the exception in doSomeThingElse and catch it in the doSomeThing method.
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
QUESTION 42
Given:
A. line x1
B. line x2
C. line x3
D. line x4
Real 33
Oracle 1z0-803 Exam
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
The variable x2 is used before it has been declared.
QUESTION 43
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result?
A. One
B. Two
C. Three
D. Compilation fails
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
In this scenario the overloading method is called with a double/float value, 4.0. This makes the third overload method to run.
Note:
The Java programming language supports overloading methods, and Java can distinguish between methods with different method signatures. This
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
means that methods within a class can have the same name if they have different parameter lists. Overloaded methods are differentiated by the number
and the type of the arguments passed into the method.
Real 34
Oracle 1z0-803 Exam
QUESTION 44
Which declaration initializes a boolean variable?
A. boolean h = 1;
B. boolean k = 0;
C. boolean m = null;
D. boolean j = (1 < 5);
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
The primitive type boolean has only two possible values: true and false. Here j is set to (1 <5), which evaluates to true.
QUESTION 45
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
D. The letter field is uninitialized.
E. It contains a method named Main instead of ma
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
The getLetter() method needs a body public static int getLetter() { }; .
Real 35
Oracle 1z0-803 Exam
QUESTION 46
Given:
This class is poorly encapsulated. You need to change the circle class to compute and return the area instead.
What three modifications are necessary to ensure that the class is being properly encapsulated?
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A. Change the access modifier of the setradius () method to private
B. Change the getArea () method
public double getArea () { return area; }
C. When the radius is set in the Circle constructor and the setRadius () method, recomputed the area and store it into the area field
D. Change the getRadius () method:
public double getRadius () {
area = Math.PI * radius * radius;
return radius;
}
Explanation/Reference:
Explanation:
QUESTION 47
Given a code fragment:
Real 36
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A. They match
They real match
B. They really match
C. They match
D. Nothing is printed to the screen
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 48
Given the following code:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
F. Change line 5 to the following:
Price = (float) 4:
G. Change line 5 to the following:
Price = (Simple) 4;
H. The code compiles and runs properly; no changes are necessary
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
Explanation:
price.price =4; is correct, not price=4;
The attribute price of the instance must be set, not the instance itself.
QUESTION 49
Given:
A. 2
B. 2
C. null
D. an infinite loop
E. compilation fails
Correct Answer: E
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Section: (none)
Explanation
Explanation/Reference:
Explanation:
The line while (--ii); will cause the compilation to fail.
ii is not a boolean value.
Real 38
Oracle 1z0-803 Exam
QUESTION 50
You are writing a method that is declared not to return a value. Which two are permitted in the method body?
Correct Answer: AD
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Any method declared void doesn't return a value. It does not need to contain a return statement, but it may do so. In such a case, a return statement can
be used to branch out of a control flow block and exit the method and is simply used like this:
return;
QUESTION 51
Identify two benefits of using ArrayList over array in software development.
Correct Answer: AD
Section: (none)
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation
Explanation/Reference:
Explanation:
ArrayList supports dynamic arrays that can grow as needed. In Java, standard arrays are of a fixed length. After arrays are created, they cannot grow or
shrink, which means that you must know in advance how many elements an array will hold. But, sometimes, you may not know until run time precisely
how large of an array you need. To handle this situation, the collections framework defines ArrayList. In essence, an ArrayList is a variable-length array
of object references. That is, an ArrayList can dynamically increase or decrease in size. Array lists are created with an initial size. When this size is
exceeded, the collection is automatically enlarged.
Real 39
Oracle 1z0-803 Exam
QUESTION 52
Which three are valid types for switch?
A. int
B. float
C. double
D. integer
E. String
F. Float
Explanation/Reference:
Explanation:
A switch works with the byte, short, char, and int primitive data types. It also works with enumerated types the String class, and a few special classes
that wrap certain primitive types:
Character, Byte, Short, and Integer.
QUESTION 53
Give:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What value should replace kk in line x to cause jj = 5 to be output?
A. -1
B. 1
C. 5
Real 40
Oracle 1z0-803 Exam
D. 8
E. 11
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
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 54
Given the code fragment:
Boolean b1 = true;
Boolean b2 = false;
int i = 0;
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
while (foo) { }
A. b1.compareTo(b2)
B. i=1
C. i == 2? -1 : 0
D. "foo".equals("bar")
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Equals works fine on strings equals produces a Boolean value.
QUESTION 55
Given:
Real 41
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What should statement1, statement2, and statement3, be respectively, in order to produce the result?
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Shape: constructor
Square: foo
Shape: foo
Real 42
Oracle 1z0-803 Exam
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
Correct Answer: D
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 56
Give:
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.*
Real 43
Oracle 1z0-803 Exam
F. The package with no name
Correct Answer: AF
Section: (none)
Explanation
Explanation/Reference:
Explanation:
For convenience, the Java compiler automatically imports three entire packages for each source file: (1) the package with no name, (2) the java.lang
package, and (3) the current package (the package for the current file).
QUESTION 57
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the reference type of myZ and what is the type of the object it references?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 58
Given:
Real 44
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result?
A. sc: class.Object
asc: class.AnotherSampleClass
B. sc: class.SampleClass
asc: class.AnotherSampleClass
C. sc: class.AnotherSampleClass
asc: class.SampleClass
D. sc: class.AnotherSampleClass
asc: class.AnotherSampleClass
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Note: The getClass method Returns the runtime class of an object. That Class object is the object that is locked by static synchronized methods of the
represented class.
Note: Because Java handles objects and arrays by reference, classes and array types are known as reference types.
QUESTION 59
Given the code fragment:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Real 45
Oracle 1z0-803 Exam
How many times is 2 printed?
A. Zero
B. Once
C. Twice
D. Thrice
E. It is not printed because compilation fails
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
The outer loop will run three times, one time each for the elements in table. The break statement breaks the inner loop immediately each time.
2 will be printed once only.
Note: If the line int ii = 0; is missing the program would not compile.
QUESTION 60
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Given:
A. Compilation fails
B. An exception is thrown at runtime
C. There is no result because this is not correct way to determine the hash code
D. Hash is: 111111, 44444444, 999999999
Real 46
Oracle 1z0-803 Exam
Correct Answer: A
Section: (none)
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation
Explanation/Reference:
Explanation:
The compilation fails as SampleClassA and SampleClassB cannot override SampleClass because the return type of SampleClass is int, while the return
type of SampleClassA and SampleClassB is long.
Note: If all three classes had the same return type the output would be:
Hash is : 111111, 44444444, 999999999
QUESTION 61
Which two will compile, and can be run successfully using the command:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: CD
Section: (none)
Explanation
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation/Reference:
Explanation:
Real 47
Oracle 1z0-803 Exam
Throws java.lang.ArrayIndexOutOfBoundsException: 2
at certquestions.Fred1.main(Fred1.java:3)
C. Prints out: [Ljava.lang.String;@39341183
D. Prints out: walls
QUESTION 62
Given:
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 63
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Real 48
Oracle 1z0-803 Exam
A. 7
B. 12
C. 19
D. Compilation fails
E. An exception is thrown at run time
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 64
Which two statements are true?
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
D. An interface can be extended by an abstract class.
E. An abstract class can be extended by a concrete class.
F. An abstract class CANNOT be extended by an abstract class.
Correct Answer: AE
Section: (none)
Explanation
Explanation/Reference:
Explanation:
http://docs.oracle.com/javase/tutorial/java/IandI/abstract.html
QUESTION 65
Given:
Real 49
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result?
A. One
B. Two
C. Three
D. Compilation fails
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation:
QUESTION 66
The catch clause argument is always of type__________.
A. Exception
B. Exception but NOT including RuntimeException
C. Throwable
D. RuntimeException
E. CheckedException
F. Error
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Because all exceptions in Java are the sub-class ofjava.lang.Exception class, you can have a
Real 50
Oracle 1z0-803 Exam
single catch block that catches an exception of type Exception only. Hence the compiler is fooled into thinking that this block can handle any exception.
See the following example:
try
{
// ...
}
catch(Exception ex)
{
// Exception handling code for ANY exception
}
You can also use the java.lang.Throwable class here, since Throwable is the parent class for the application-specific Exception classes. However, this is
discouraged in Java programming circles. This is because Throwable happens to also be the parent class for the non-application specific Error classes
which are not meant to be handled explicitly as they are catered for by the JVM itself.
Note: The Throwable class is the superclass of all errors and exceptions in the Java language. Only objects that are instances of this class (or one of its
subclasses) are thrown by the Java Virtual Machine or can be thrown by the Java throw statement. A throwable contains a snapshot of the execution
stack of its thread at the time it was created. It can also contain a message string that gives more information about the error.
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
QUESTION 67
Given the code fragment:
2. list.add(1001);
3. list.add(1002);
4. System.out.println(list.get(list.size()));
Real 51
Oracle 1z0-803 Exam
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
The code compiles fine.
At runtime an IndexOutOfBoundsException is thrown when the second list item is added.
QUESTION 68
View the Exhibit.
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
public String getName() { return name; }
this.name = name;
Given
Real 52
Oracle 1z0-803 Exam
Which statement sets the name of the Hat instance?
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 69
public class Two {
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
try {
doStuff();
system.out.println("1");
catch {
system.out.println("2");
}}
System.out.println("3 ");
System.out.println("4");
Real 53
Oracle 1z0-803 Exam
A. 2
B. 4
C. 1
D. 1
Correct Answer: AB
Section: (none)
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation
Explanation/Reference:
Explanation:
A: Output is 2 if Math.random() is greater than 0.5.
B: If Math.random() returns a value less equal to 0.5, the code won't throw an exception, it will continue with the doMore() method which will println "4"
after which the program will continue with the doStuff() method and will println "3", after that we will be back in main() and the program will print "1".
QUESTION 70
Given:
ii = ii +1;
A. ii = 0
ii = 2
B. ii = 0
ii = 1
ii = 2
Real 54
Oracle 1z0-803 Exam
ii = 3
C. ii =
D. Compilation fails.
Correct Answer: A
Section: (none)
Explanation
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation/Reference:
Explanation:
QUESTION 71
Given the code fragment:
Which pair of load and modify statement should be inserted in the code?
Real 55
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Oracle 1z0-803 Exam
The load statement should set the array's x row and y column value to the sum of x and y
The modify statement should modify the array's x row and y column value by multiplying it by 2
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 72
Given:
if ( "bb".equals(ss)) {
continue;
System.out.println(ss);
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
if ( "cc".equals(ss)) {
break;
Real 56
Oracle 1z0-803 Exam
}
A. aa
cc
B. aa
bb
cc
C. cc
dd
D. cc
E. Compilation fails.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 73
1. class StaticMethods {
3. two();
4. StaticMethods.two();
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
5. three();
6. StaticMethods.four();
7. }
9. void three() {
10. one();
11. StaticMethods.two();
12. four();
13. StaticMethods.four();
Real 57
Oracle 1z0-803 Exam
14. }
16. }
A. line 3
B. line 4
C. line 5
D. line 6
E. line 10
F. line 11
G. line 12
H. line 13
Explanation/Reference:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation:
QUESTION 74
Which is a valid abstract class?
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Real 58
Oracle 1z0-803 Exam
Explanation:
QUESTION 75
View the exhibit:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
public boolean fulltime = true;
return fulltime;
Given:
bob.name = "Bob";
bob.age = 18;
bob.year = 1982;
Real 59
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 76
Given the code fragment:
int age = 4;
System.out.println(str);
And
Using StringBuilder, which code fragment is the best potion to build and print the following string My dog Spot is 4
Correct Answer: AD
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 77
Given:
Real 60
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
public class Main {
try {
doSomething();
catch (SpecialException e) {
System.out.println(e);
}}
ages[4] = 17;
doSomethingElse();
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
The following line causes a runtime exception (as the index is out of bounds):
ages[4] = 17;
Real 61
Oracle 1z0-803 Exam
Note: The third kind of exception (compared to checked exceptions and errors) is the runtime exception. These are exceptional conditions that are
internal to the application, and that the application usually cannot anticipate or recover from. These usually indicate programming bugs, such as logic
errors or improper use of an API.
Runtime exceptions are not subject to the Catch or Specify Requirement. Runtime exceptions are those indicated by RuntimeException and its
subclasses.
QUESTION 78
View the exhibit:
return fulltime;
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Which line of code initializes a student instance?
A. Student student1;
B. Student student1 = Student.new();
C. Student student1 = new Student();
D. Student student1 = Student();
Real 62
Oracle 1z0-803 Exam
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 79
int [] array = {1,2,3,4,5};
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
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 80
int i, j=0;
i = (3* 2 +4 +5 ) ;
j = (3 * ((2+4) + 5));
System.out.println("i:"+ i + "\nj":+j);
Real 63
Oracle 1z0-803 Exam
What is the result?
A. Option A
B. Option B
C. Option C
D. Option D
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 81
boolean log3 = ( 5.0 != 6.0) && ( 4 != 5);
A. log3:false
log4:true
B. log3:true
log4:true
C. log3:true
log4:false
D. log3:false
Real 64
Oracle 1z0-803 Exam
log4:false
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 82
Which statement will empty the contents of a StringBuilder variable named sb?
A. sb.deleteAll();
B. sb.delete(0, sb.size());
C. sb.delete(0, sb.length());
D. sb.removeAll();
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 83
Class StaticField {
static int i = 7;
obj.i++;
StaticField.i++;
obj.i++;
A. 10 10
B. 8 9
Real 65
Oracle 1z0-803 Exam
C. 9 8
D. 7 10
Correct Answer: A
Section: (none)
Explanation
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation/Reference:
Explanation:
QUESTION 84
Which two are valid array declaration?
A. Object array[];
B. Boolean array[3];
C. int[] array;
D. Float[2] array;
Correct Answer: AC
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 85
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");
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Real 66
Oracle 1z0-803 Exam
return 0.0;
new Overloading().x(4.0);
A. One
B. Two
C. Three
D. Compilation fails.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 86
Given:
void main() {
System.out.println("one");
System.out.println("two");
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
}
System.out.println("three");
Real 67
Oracle 1z0-803 Exam
System.out.println("four");
A. one
B. two
C. three
D. four
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 87
Given:
int j, int k;
ew ScopeTest().doStuff(); }
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
void doStuff() {
nt x = 5;
oStuff2();
System.out.println("x");
void doStuff2() {
nt y = 7;
ystem.out.println("y");
ystem.out.println("z");
Real 68
Oracle 1z0-803 Exam
ystem.out.println("y");
A. j
B. k
C. x
D. y
E. z
Correct Answer: AB
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 88
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A method is declared to take three arguments. A program calls this method and passes only two arguments. What is the results?
A. Compilation fails.
B. The third argument is given the value null.
C. The third argument is given the value void.
D. The third argument is given the value zero.
E. The third argument is given the appropriate falsy value for its declared type. F) An exception occurs when the method attempts to access the third
argument.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 89
public class ForTest {
for ( foo ) {
Real 69
Oracle 1z0-803 Exam
}
Which three are valid replacements for foo so that the program will compiled and run?
A. int i: array
B. int i = 0; i < 1; i++
C. ;;
D. ; i < 1; i++
E. ; i < 1;
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Correct Answer: ABC
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 90
Given:
sc = asc;
}}
Correct Answer: D
Section: (none)
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation
Explanation/Reference:
Explanation:
QUESTION 91
Given the code fragment:
int b = 3;
System.out.println("square ");
}{
System.out.println("circle ");
System.out.println("...");
A. square...
B. circle...
C. squarecircle...
D. Compilation fails.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 92
What is the proper way to defined a method that take two int values and returns their sum as an int value?
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
B. int sum(int first, second) { return first + second; }
C. sum(int first, int second) { return first + second; }
D. int sum(int first, int second) { return first + second; }
E. void sum (int first, int second) { return first + second; }
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 93
Which two are Java Exception classes?
A. SercurityException
B. DuplicatePathException
C. IllegalArgumentException
D. TooManyArgumentsException
Correct Answer: AC
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 94
Given the for loop construct:
statement;
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.
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
C. When expr2 evaluates to false, the loop terminates. It is evaluated only after each iteration through the loop.
D. The expression expr3 must be present. It is evaluated after each iteration through the loop.
Correct Answer: BC
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Real 72
Oracle 1z0-803 Exam
QUESTION 95
public class StringReplace {
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!
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 96
Which two statements are true for a two-dimensional array?
Correct Answer: AD
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 97
Which three statements are benefits of encapsulation?
Explanation/Reference:
Explanation:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
QUESTION 98
The protected modifier on a Field declaration within a public class means that the field ______________.
A. Cannot be modified
B. Can be read but not written from outside the class
C. Can be read and written from this class and its subclasses only within the same package
D. Can be read and written from this class and its subclasses defined in any package
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Reference:
http://beginnersbook.com/2013/05/java-access-modifiers/
QUESTION 99
Given:
Real 74
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result?
A. Initialized
Started
B. Initialized
Started
Initialized
C. Compilation fails
D. An exception is thrown at runtime
Correct Answer: B
Section: (none)
Explanation
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation/Reference:
Explanation:
QUESTION 100
Given:
Real 75
Oracle 1z0-803 Exam
A. X XX
B. XYX
C. YYX
D. Y YY
Correct Answer: D
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 101
Given:
Real 76
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A. ns = 50 S = 125
ns = 125 S = 125
ns = 100 S = 125
B. ns = 50 S = 125
ns = 125 S = 125
ns = 0 S = 125
C. ns = 50 S = 50
ns = 125 S = 125
ns = 100 S = 100
D. ns = 50 S = 50
ns = 125 S = 125
ns = 0 S = 125
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 102
Given:
Class A { }
Class B { }
Interface X { }
Real 77
Oracle 1z0-803 Exam
Interface Y { }
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Correct Answer: AE
Section: (none)
Explanation
Explanation/Reference:
Explanation: extends is for extending a class.
QUESTION 103
Given the code fragment
A. t.fvar = 200;
B. cvar = 400;
C. fvar = 200;
cvar = 400;
D. this.fvar = 200;
this.cvar = 400;
E. t.fvar = 200;
Test2.cvar = 400;
F. this.fvar = 200;
Real 78
Oracle 1z0-803 Exam
Test2.cvar = 400;
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 104
View the exhibit.
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Which change enables the code to print the following?
James age: 20
Williams age: 32
A. Replacing line 5 with public static void main (String [] args) throws MissingInfoException, Real 79
Oracle 1z0-803 Exam
AgeOutofRangeException {
B. Replacing line 5 with public static void main (String [] args) throws.Exception {
C. Enclosing line 6 and line 7 within a try block and adding:
catch(Exception e1) { //code goes here}
catch (missingInfoException e2) { //code goes here}
catch (AgeOutofRangeException e3) {//code goes here}
D. Enclosing line 6 and line 7 within a try block and adding:
catch (missingInfoException e2) { //code goes here}
catch (AgeOutofRangeException e3) {//code goes here}
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 105
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result?
A. 0
Done
B. First Exception
Done
C. Second Exception
D. Done
Third Exception
E. Third Exception
Real 80
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 106
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;
Correct Answer: B
Section: (none)
Explanation
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation/Reference:
Explanation:
QUESTION 107
Given:
Real 81
Oracle 1z0-803 Exam
A. Red 0
Orange 0
Green 3
B. Red 0
Orange 0
Green 6
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
C. Red 0
Orange 1
D. Green 4
E. Compilation fails
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 108
Given the code fragment:
Real 82
Oracle 1z0-803 Exam
A. Found Red
Found Default
B. Found Teal
C. Found Red
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Found Blue
Found Teal
D. Found Red
Found Blue
Found Teal
Found Default
E. Found Default
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 109
Given:
Real 83
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A. Ym
Xm2
B. Ym
Xm1
C. Compilation fails
D. A ClassCastException is thrown at runtime
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation:
QUESTION 110
Given:
Real 84
Oracle 1z0-803 Exam
What is the result?
A. 2468
B. 24689
C. 1357
D. 13579
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 111
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result?
A. 678
B. 789
C. 012
D. 6 8 10
E. Compilation fails
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 112
Given:
Real 85
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
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
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 113
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result?
Real 86
Oracle 1z0-803 Exam
A. 100
B. Compilation fails due to an error in line n1
C. Compilation fails due to an error at line n2
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
D. Compilation fails due to an error at line n3
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 114
Given:
A. hEllOjAvA!
B. Hello java!
C. Out of limits
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
hEllOjAvA!
D. Out of limits
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 115
Given:
Real 87
Oracle 1z0-803 Exam
A. 10 : 22 : 20
B. 10 : 22 : 22
C. 10 : 22 : 6
D. 10 : 30 : 6
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
QUESTION 116
Given the code fragment:
A. 20
B. 25
C. 29
D. Compilation fails
E. AnArrayIndexOutOfBoundsException is thrown at runtime
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Real 88
Oracle 1z0-803 Exam
QUESTION 117
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 118
Which two statements are true for a two-dimensional array of primitive data type?
Correct Answer: CD
Section: (none)
Explanation
Explanation/Reference:
Explanation: http://stackoverflow.com/questions/12806739/is-an-array-a-primitive-type-or-an- object-or-something-else-entirely
QUESTION 119
Real 89
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Oracle 1z0-803 Exam
Given the code fragment:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Real 90
Oracle 1z0-803 Exam
QUESTION 120
Given:
A. Null
B. Compilation fails
C. An exception is thrown at runtime
D. 0
Correct Answer: A
Section: (none)
Explanation
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation/Reference:
Explanation:
QUESTION 121
Given:
Real 91
Oracle 1z0-803 Exam
A. Marrown
String out of limits
JesOran
B. Marrown
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
String out of limits
Array out of limits
C. Marrown
String out of limits
D. Marrown
NanRed
JesOran
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 122
Given:
Real 92
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
F. Option F
Correct Answer: BE
Section: (none)
Explanation
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation/Reference:
Explanation: When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class (E).
However, if it does not, then the subclass must also be declared abstract (B).
Note: An abstract class is a class that is declared abstract--it may or may not include abstract methods. Abstract classes cannot be instantiated, but they
can be subclassed.
QUESTION 123
Given the class definitions:
Real 93
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result?
A. Java
Java
Java
B. Java
Jeve
va
C. Java
Jeve
ve
D. Compilation fails
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 124
Given:
Real 94
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result?
A. Good Day!
Good Luck!
B. Good Day!
Good Day!
C. Good Luck!
Good Day!
D. Good Luck!
Good Luck!
E. Compilation fails
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 125
Which two items can legally be contained within a java class declaration?
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A. An import statement
B. A field declaration
C. A package declaration
D. A method declaration
Correct Answer: BD
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Reference:
http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html
Real 95
Oracle 1z0-803 Exam
QUESTION 126
Given the fragments:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Which line causes a compilation error?
A. Line n1
B. Line n2
C. Line n3
D. Line n4
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 127
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Real 96
Oracle 1z0-803 Exam
What is the result?
A. box
B. nbo
C. bo
D. nb
E. An exception is thrown at runtime
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 128
Given the code fragments:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
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
Section: (none)
Explanation
Explanation/Reference:
Explanation:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Real 97
Oracle 1z0-803 Exam
QUESTION 129
Given:
A. Shining Sun
Shining Sun
Shining Sun
B. Shining Sun
Twinkling Star
Shining Sun
C. Compilation fails
D. A ClassCastException is thrown at runtime
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 130
Given the code fragment:
Real 98
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A. Super
Sub
Sub
B. Contract
Contract
Super
C. Compilation fails at line n1
D. Compilation fails at line n2
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 131
Given the code fragment:
Real 99
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
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
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 132
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
Real 100
Oracle 1z0-803 Exam
Correct Answer: BC
Section: (none)
Explanation
Explanation/Reference:
Explanation: When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class (C).
However, if it does not, then the subclass must also be declared abstract (B).
Note: An abstract class is a class that is declared abstract--it may or may not include abstract methods. Abstract classes cannot be instantiated, but they
can be subclassed.
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
QUESTION 133
Which two actions will improve the encapsulation of a class?
Correct Answer: AD
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Reference:
http://www.tutorialspoint.com/java/java_access_modifiers.htm
QUESTION 134
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Real 101
Oracle 1z0-803 Exam
A. a, e
i, o
B. a, e
o, o
C. e, e
I, o
D. e, e
o, o
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
QUESTION 135
Given:
The class is poorly encapsulated. You need to change the circle class to compute and return the area instead.
Which two modifications are necessary to ensure that the class is being properly encapsulated?
Correct Answer: BD
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Real 102
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
QUESTION 136
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 137
Real 103
Oracle 1z0-803 Exam
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Which code fragment, when inserted at line 7, enables the code print true?
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Real 104
Oracle 1z0-803 Exam
QUESTION 138
Given the code fragment:
A. 10 Hello world!
B. 10 Hello universe!
C. 9 Hello world!
D. Compilation fails.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 139
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
And the commands:
Javac Test.java
A. Number us : 12345
B. A NullPointerException is thrown at runtime
Real 105
Oracle 1z0-803 Exam
C. A NumberFormatException is thrown at runtime
D. AnArrayIndexOutOfBoundException is thrown at runtime.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 140
Given the code fragment:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Which code fragment, when inserted at // insert code here, enables the code to compile and and print a b c?
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 141
Given the code fragment:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Real 106
Oracle 1z0-803 Exam
A. 28false29
true
B. 285 < 429
true
C. true
true
D. compilation fails
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 142
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result?
A. x: 1 y: 2
B. 3 y: 4
C. x: 0 y: 0
D. 3 y: 4
Real 107
Oracle 1z0-803 Exam
E. x: 1 y: 2
F. 0 y: 0
G. x: 0 y: 0
H. 0 y: 0
Correct Answer: C
Section: (none)
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation
Explanation/Reference:
Explanation:
QUESTION 143
Given the code fragment:
Correct Answer: C
Section: (none)
Explanation
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation/Reference:
Explanation:
QUESTION 144
Given:
Real 108
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 145
Given the code fragment:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Real 109
Oracle 1z0-803 Exam
What could expression1 and expression2 be, respectively, in order to produce output 8, 16?
A. + +a, - -b
B. + +a, b- -
C. A+ +, - - b
D. A + +, b - -
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 146
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result?
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 147
Given:
Real 110
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result?
A. Compilation fails
B. The code compiles, but does not execute.
C. Paildrome
D. Wow
E. Mom
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 148
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
And the commands:
Javac Jump.java
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 149
Which code fragment cause a compilation error?
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
C. float flt = 100;
D. double y1 = 203.22;
floatflt = y1
E. int y2 = 100;
floatflt = (float) y2;
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 150
Given:
Real 112
Oracle 1z0-803 Exam
What is the result?
A. 10 20 30 40
B. 0 0 30 40
C. Compilation fails
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
D. An exception is thrown at runtime
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 151
Given:
A. 1
B. 1
C. 2
D. Compilation fails
E. The loop executes infinite times
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Real 113
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Oracle 1z0-803 Exam
QUESTION 152
Given:
Which code fragment, when inserted at line 14, enables the code to print Mike Found?
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 153
Give:
Real 114
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A. 1525
B. 13
C. Compilation fails
D. An exception is thrown at runtime
E. The program fails to execute due to runtime error
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 154
Given:
Real 115
Oracle 1z0-803 Exam
What is the result?
A. true true
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
B. true false
C. false true
D. false false
E. Compilation fails
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 155
Given the code in a file Traveler.java:
Javac Traveler.java
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
C. An exception is thrown at runtime
D. The program fails to execute due to a runtime error
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Real 116
Oracle 1z0-803 Exam
QUESTION 156
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Which constructor initializes the variable x3?
Correct Answer: C
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 157
Given:
Real 117
Oracle 1z0-803 Exam
How many objects have been created when the line / / do complex stuff is reached?
A. Two
B. Three
C. Four
D. Six
Correct Answer: C
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 158
Given:
Real 118
Oracle 1z0-803 Exam
What is result?
A. Successful
B. Unsuccessful
C. Compilation fails
D. An exception is thrown at runtime
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
QUESTION 159
Given:
A. 2 4 6 8 10 12
B. 2 4 6 8 10 12 14
C. Compilation fails
D. The program prints multiple of 2 infinite times
E. The program prints nothing
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Real 119
Oracle 1z0-803 Exam
QUESTION 160
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Given the fragment:
A. 13480.0
B. 13480.02
C. Compilation fails
D. An exception is thrown at runtime
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 161
Given:
Which code fragment, when inserted at line 9, enables the code to print true?
Correct Answer: B
Section: (none)
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation
Explanation/Reference:
Explanation:
QUESTION 162
Real 120
Oracle 1z0-803 Exam
Given the code fragment:
A. 10 8 6 4 2 0
B. 10 8 6 4 2
C. AnArithmeticException is thrown at runtime
D. The program goes into an infinite loop outputting: 10 8 6 4 2 0. . .
E. Compilation fails
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 163
Given the classes:
* AssertionError
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
* ArithmeticException
* ArrayIndexOutofBoundsException
* FileNotFoundException
* IllegalArgumentException
* IOError
* IOException
* NumberFormatException
* SQLException
Real 121
Oracle 1z0-803 Exam
Which option lists only those classes that belong to the unchecked exception category?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation: Not B: IOError and IOException are both checked errors. Not C, not D, not E: FileNotFoundException is a checked error.
Note:
Checked exceptions:
* represent invalid conditions in areas outside the immediate control of the program (invalid user input, database problems, network outages, absent
files)
* are subclasses of Exception
* a method is obliged to establish a policy for all checked exceptions thrown by its implementation (either pass the checked exception further up the
stack, or handle it somehow)
Note:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Unchecked exceptions:
* represent defects in the program (bugs) - often invalid arguments passed to a non-private method. To quote from The Java Programming Language,
by Gosling, Arnold, and Holmes:
"Unchecked runtime exceptions represent conditions that, generally speaking, reflect errors in your program's logic and cannot be reasonably recovered
from at run time."
* are subclasses of RuntimeException, and are usually implemented using IllegalArgumentException, NullPointerException, or IllegalStateException
* method is not obliged to establish a policy for the unchecked exceptions thrown by its implementation (and they almost always do not do so)
QUESTION 164
Given:
ref =20;
pv = 20;
Real 122
Oracle 1z0-803 Exam
}
doubling(iObj++, iVar++);
A. 11, 11
B. 10, 10
C. 21, 11
D. 20, 20
E. 11, 12
Correct Answer: A
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Section: (none)
Explanation
Explanation/Reference:
Explanation: The code doubling(iObj++, iVar++); increases both variables from to 10 to 11.
QUESTION 165
Given:
class Mid {
int n1 = 22, n2 = 2;
System.out.print(n3);
Real 123
Oracle 1z0-803 Exam
}
Which two code fragments, when inserted at // insert code here, enable the code to compile and print 12?
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
int n3 = m1.findMid(n1, n2);
E. int n3 = Calc.findMid(n1, n2);
Correct Answer: AD
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Incorrect:
Not B: circular definition of n3.
Not C: Compilation error. line Calc c = new Mid();
required: Calc
found: Mid
Not E: Compilation error. line int n3 = Calc.findMid(n1, n2); non-static method findMid(int,int) cannot be referenced from a static context
QUESTION 166
Given:
import java.util.*;
String s2 = s1.toString();
lst.add(s2);
Real 124
Oracle 1z0-803 Exam
System.out.println(s1.getClass());
System.out.println(s2.getClass());
System.out.println(lst.getClass());
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
}
A. class java.lang.String
class java.lang.String
class java.util.ArrayList
B. class java.lang.Object
class java.lang. Object
class java.util.Collection
C. class java.lang.StringBuilder
class java.lang.String
class java.util.ArrayList
D. class java.lang.StringBuilder
class java.lang.String
class java.util.List
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation: class java.lang.StringBuilder
class java.lang.String
class java.util.ArrayList
QUESTION 167
Given:
public int x;
public int y;
x = nx; y =ny;
Real 125
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
updateSum();
Which three members must have the private access modifier to ensure that this invariant is maintained?
A. The x field
B. The y field
C. The sum field
D. The ComputerSum ( ) constructor
E. The setX ( ) method
F. The setY ( ) method
Explanation/Reference:
Explanation: The sum field and the two methods (setX and SetY) that updates the sum field.
QUESTION 168
Given the following four Java file definitions:
// Foo.java
package facades;
// Boo.java
package facades;
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
public interface Boo extends Foo { }
// Woofy.java
Real 126
Oracle 1z0-803 Exam
package org.domain
// line n1
// Test.java
package.org;
A. At line n1, Insert: import facades;At line n2, insert:import facades;import org.domain;
B. At line n1, Insert: import facades.*;At line n2, insert:import facades;import org.*;
C. At line n1, Insert: import facades.*;At line n2, insert:import facades.Boo;import org.*;
D. At line n1, Insert: import facades.Foo, Boo;At line n2, insert:import org.domain.Woofy;
E. At line n1, Insert: import facades.*;At line n2, insert:import facades;import org.domain.Woofy;
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 169
Given:
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
public class SuperTest {
statement1
statement2
statement3
Real 127
Oracle 1z0-803 Exam
}
class Shape {
public Shape() {
System.out.println("Shape: constructor");
System.out.println("Shape: foo");
public Square() {
super();
System.out.println("Square: constructor");
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
}
super.foo();
System.out.println("Square: foo");
Real 128
Oracle 1z0-803 Exam
What should statement1, statement2, and statement3, be respectively, in order to produce the result?
Shape: constructor
Square: foo
Shape: foo
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
E. Square square = new Square ();
square.foo ();
square.foo ();
F. Square square = new Square();
square.foo("bar");
square.foo();
Correct Answer: F
Section: (none)
Explanation
Explanation/Reference:
QUESTION 170
Given:
int num;
obj4.num += 10;
Real 129
Oracle 1z0-803 Exam
MarkList obj1 = new MarkList();
obj2.num = 60;
graceMarks(obj2);
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
}
A. 1
B. 2
C. 3
D. 4
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation: obj1 and obj3.
when you do e2 = e1 you're copying object references - you're not making a copy of the object - and so the variables e1 and e2 will both point to the
same object.
QUESTION 171
Given:
class Cake {
int model;
String flavor;
Cake() {
model = 0;
flavor = "Unknown";
Real 130
Oracle 1z0-803 Exam
public class Test {
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Cake c = new Cake();
bake1(c);
bake2(c);
A. flavor = "Strawberry";
B. model = 1200;
return c;
}
public static void bake2(Cake c) {
C. flavor = "Chocolate";
D. model = 1230;
return;
}
}
What is the result?
E. 0 unknown
0 unknown
F. 1200 Strawberry
1200 Strawberry
G. 1200 Strawberry
1230 Chocolate
H. Compilation fails
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation: 1200 Strawberry
Real 131
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Oracle 1z0-803 Exam
1230 Chocolate
QUESTION 172
Given:
return type;
this.type = type;
obj1.setType(null);
obj2.setType("Fresco");
A. : Fresco
B. null : Fresco
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
C. Fresco : Fresco
D. A NullPointerException is thrown at runtime
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Real 132
Oracle 1z0-803 Exam
Explanation:
QUESTION 173
Given:
class Base {
obj.setNum(3);
Which two options, when inserted independently inside class Base, ensure that the class is being properly encapsulated and allow the program to
execute and print the square of the number?
A. private int num; public int getNum() { return num; }public void setNum(int num) { this.num = num;}
B. public int num; protected public int getNum() { return num; }protected public void setNum(int num) { this.num = num;}
C. private int num;public int getNum() {return num;} private void setNum(int num) { this.num = num;}
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
D. protected int num; public int getNum() { return num; } public void setNum(int num) { this.num = num;}
E. protected int num; private int getNum() { return num; } public void setNum(int num) { this.num = num;}
Correct Answer: AD
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Incorrect:
Not B: illegal combination of modifiers: protected and public
Real 133
Oracle 1z0-803 Exam
QUESTION 174
Given:
arr[0] = 1;
arr[1] = 2;
arr[2] = 4;
arr[3] = 5;
int sum = 0;
try {
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
}
} catch (Exception e) {
System.out.println("Invalid index");
System.out.println(sum);
A. 12
B. Invalid Index
Real 134
Oracle 1z0-803 Exam
C. Invalid Index
D. Compilation fails
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation: The loop ( for (int pos = 0; pos <= 4; pos++) { ), it should be pos <= 3, causes an exception, which is caught. Then the correct sum is
printed.
QUESTION 175
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
for (String str : str2) {
str3 = str3+str;
boolean b2 = (str1.equals(str3));
System.out.print(b1+", "+b2);
A. true, false
B. false, true
C. true, true
D. false, false
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation: == strict equality.
Real 135
Oracle 1z0-803 Exam
QUESTION 176
Given the code fragment:
iArray[2] = iArray[0];
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
iArray[0] = iArray[1];
iArray[1] = iArray[2];
A. 68, 65, 69
B. 68, 65, 65
C. 65, 68, 65
D. 65, 68, 69
E. Compilation fails
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation: 68 65 65
QUESTION 177
Given:
int a = 0, z=10;
while (a < z) {
a++;
Real 136
Oracle 1z0-803 Exam
--z;
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
System.out.print(a + " : " + z);
A. 5:5
B. 6:4
C. 6:5
D. 5:4
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation: 5 : 5
QUESTION 178
Given:
ii++;
A. ii = 1
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
ii = 2
Real 137
Oracle 1z0-803 Exam
B. Compilation fails
C. The program prints nothing
D. The program goes into an infinite loop with no output
E. The program goes to an infinite loop outputting:
ii = 1
ii = 1
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation: The while statement is incorrect. It has the syntax of a for statement.
The while statement continually executes a block of statements while a particular condition is true.
Its syntax can be expressed as:
while (expression) {
statement(s)
}
The while statement evaluates expression, which must return a boolean value. If the expression evaluates to true, the while statement executes the
statement(s) in the while block. The while statement continues testing the expression and executing its block until the expression evaluates to false.
QUESTION 179
Given:
String s = "123";
if (s.length() >2)
A. concat("456");
for(int x = 0; x <3; x++)
s += "x";
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
System.out.println(s);
}
Real 138
Oracle 1z0-803 Exam
}
What is the result?
B. 123
C. 123xxx
D. 123456
E. 123456xxx
F. Compilation fails
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation: 123xxx
QUESTION 180
Given the code fragment:
int y = 22 % 3;
A. 1.0, 1
B. 1.0f, 1
C. 7.33, 7
D. Compilation fails
E. An exception is thrown at runtime
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation: 1.0, 1
Real 139
Oracle 1z0-803 Exam
QUESTION 181
Which three statements are true about the structure of a Java class?
Explanation/Reference:
Explanation: A: Private constructors prevent a class from being explicitly instantiated by its callers.
If the programmer does not provide a constructor for a class, then the system will always provide a default, public no-argument constructor. To disable
this default constructor, simply add a private no-argument constructor to the class. This private constructor may be empty.
B: The following works fine:
int cake() {
int cake=0;
return (1);
}
C: We can overload static method in Java. In terms of method overloading static method are just like normal methods and in order to overload static
method you need to provide another static method with same name but different method signature.
Incorrect:
Not D: Only a public class in an application need to have a main method.
Not E:
Example:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
class A
{
public string something;
public int a;
}
Q: What do you call classes without methods?
Most of the time: An anti pattern.
Why? Because it faciliates procedural programming with "Operator" classes and data structures. You separate data and behaviour which isn't exactly
good OOP.
Real 140
Oracle 1z0-803 Exam
Read only datastructures meant to exchange data, derived from a business/domain object.
Well sometimes, you just gotta have those structures to hold data that is just plain and simple and has no operations on it.
Not F: Fields need to be initialtized. If not the code will not compile.
Example:
Uncompilable source code - variable x might not have been initialized
QUESTION 182
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
System.out.print("Pass");
} else {
System.out.print("Fail");
Real 141
Oracle 1z0-803 Exam
int marks = Integer.parseInt(args[2]);
try {
new GradingProcess().verify(marks));
} catch(Exception e) {
System.out.print(e.getClass());
A. Pass
B. Fail
C. Class MarketOutOfBoundsException
D. Class IndexOutOfBoundsException
E. Class Exception
Correct Answer: C
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Section: (none)
Explanation
Explanation/Reference:
Explanation: The value 104 will cause a MarketOutOfBoundsException
QUESTION 183
Given the code fragment:
Sb.append ("world");
A. sb.insert(0,"Hello ");
Real 142
Oracle 1z0-803 Exam
System.out.println(sb);
B. sb.append(0,"Hello ");
System.out.println(sb);
C. sb.add(0,"Hello ");
System.out.println(sb);
D. sb.set(0,"Hello ");
System.out.println(sb);D
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation: The java.lang.StringBuilder.insert(int offset, char c) method inserts the string representation of the char argument into this sequence. The
second argument is inserted into the contents of this sequence at the position indicated by offset. The length of this sequence increases by one.The
offset argument must be greater than or equal to 0, and less than or equal to the length of this sequence.
QUESTION 184
Given:
package p1;
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
public interface DoInterface {
package p3;
import p1.DoInterface;
Real 143
Oracle 1z0-803 Exam
public static void main(String[] args) {
doi.method1(100);
doi.method2(100);
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation: Private members (both fields and methods) are only accessible inside the class they are declared or inside inner classes. private keyword
is one of four access modifier provided by Java and its a most restrictive among all four e.g. public, default(package), protected and private.
QUESTION 185
Given the fragment:
Which code fragment when inserted at line '// insert code fragment here', enables the code to successfully change arra elements to uppercase?
Real 144
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
D. toUpperCase();
}
}
E. for (int i:arra.length) {
for (String x:arra) {
arra[i].toUpperCase();
}
}
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Incorrect:
not A: arra.length is 3, but the subarrays have 2, 3 and 4 elements. Index will be out of bound. not B: The subarrys are of different lengths. Index will be
out of bound.
not D: Compile error.
QUESTION 186
Given the code fragment:
Real 145
Oracle 1z0-803 Exam
}
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
arr[0] = class1;
arr[1] = class2;
arr[2] = class3;
Test.doPrint();
Which code fragment, when inserted at line //insert code here, enables the code to print COJ?
A. int i = 0;
for (String[] sub: arr) {
int j = sub.length -1;
for (String str: sub) {
System.out.println(str[j]);
i++;
}
}
B. private static void doPrint() {
for (int i = 0;i < arr.length;i++) {
int j = arr[i].length-1;
System.out.print(arr[i][j]);
}
}
C. int i = 0;
for (String[] sub: arr[][]) {
int j = sub.length;
System.out.print(arr[i][j]);
i++;
}
D. for (int i = 0;i < arr.length-1;i++) {
int j = arr[i].length-1;
System.out.print(arr[i][j]);
i++;
Real 146
Oracle 1z0-803 Exam
}
Correct Answer: B
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Incorrect:
not A: The following line causes a compile error:
System.out.println(str[j]);
Not C: Compile erro line:
for (String[] sub: arr[][])
not D: Output: C
QUESTION 187
Given:
char c;
boolean b;
float f;
void printAll() {
A. printAll();
}
}
What is the result?
Real 147
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
B. c = null
b = false
f = 0.0F
C. c = 0
b = false
f = 0.0f
D. c = null
b = true
f = 0.0
E. c =
b = false
f = 0.0
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 188
Given the code fragment:
if ("tom".equals(cartoons[0])) {
counter++;
} else if ("tom".equals(cartoons[1])) {
counter++;
} else if ("tom".equals(cartoons[2])) {
counter++;
} else if ("tom".equals(cartoons[3])) {
counter++;
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
}
System.out.print(counter);
Real 148
Oracle 1z0-803 Exam
A. 1
B. 2
C. 4
D. 0
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation: Counter++ will be executed only once because of the else if constructs.
QUESTION 189
Given:
int day = 1;
switch (day) {
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
case "5": System.out.print("Jupiter");
Which two modifications, made independently, enable the code to compile and run?
Correct Answer: AC
Section: (none)
Explanation
Explanation/Reference:
Explanation: The following will work fine:
QUESTION 190
Given:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
public class Test {
try {
arr[1] = "Unix";
arr[2] = "Linux";
arr[3] = "Solarios";
Real 150
Oracle 1z0-803 Exam
}
} catch(Exception e) {
System.out.print (e.getClass());
Correct Answer: B
Section: (none)
Explanation
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation/Reference:
Explanation: null Unix Linux Solarios
QUESTION 191
Given the code fragment
int var3 = 0;
if (var2 < 0) {
var3 = var2++;
} else {
var3 = --var2;
System.out.println(var3);
Real 151
Oracle 1z0-803 Exam
What is the result?
A. 6
B. 4
C. 5
D. 5
E. 4
F. Compilation fails
Correct Answer: C
Section: (none)
Explanation
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation/Reference:
Explanation:
QUESTION 192
Given the code fragment:
colors.add("green");
colors.add("red");
colors.add("blue");
colors.add("yellow");
colors.remove(2);
colors.add(3,"cyan");
System.out.print(colors);
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation: First the list [green, red, blue, yellow] is build.
The blue element is removed:
[green, red, yellow]
Finally the element cyan is added at then end of the list (index 3).
Real 152
Oracle 1z0-803 Exam
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
QUESTION 193
Given:
A. Result = 2
B. Result = 3
C. Result = 28
D. Result = 29
E. Result = 30
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 194
Given:
class Sports {
int num_players;
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Real 153
Oracle 1z0-803 Exam
num_players = np;
name = sname;
ground_condition = sground;
int num_umpires;
int num_substitutes;
Which code fragment can be inserted at line //insert code here to enable the code to compile?
A. Cricket() {
super(11, "Cricket", "Condidtion OK");
num_umpires =3;
num_substitutes=2;
}
B. Cricket() {
super.ground_condition = "Condition OK";
super.name="Cricket";
super.num_players = 11;
num_umpires =3;
num_substitutes=2;
}
C. Cricket() {
this(3,2);
super(11, "Cricket", "Condidtion OK");
}
Cricket(int nu, ns) {
this.num_umpires =nu;
this.num_substitutes=ns;
}
D. Cricket() {
this.num_umpires =3;
this.num_substitutes=2;
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
super(11, "Cricket", "Condidtion OK");
}
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Real 154
Oracle 1z0-803 Exam
Incorrect:
not C, not D: call to super must be the first statement in constructor.
QUESTION 195
Given:
public class X {
static int i;
int j;
X x1 = new X();
X x2 = new X();
x1.i = 3;
x1.j = 4;
x2.i = 5;
x2.j = 6;
System.out.println(
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
x1.j + " "+
x2.j);
A. 3456
B. 3436
C. 5456
D. 3646
Real 155
Oracle 1z0-803 Exam
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 196
Which statement is true about the default constructor of a top-level class?
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation: In both Java and C#, a "default constructor" refers to a nullary constructor that is automatically generated by the compiler if no constructors
have been defined for the class. The default constructor is also empty, meaning that it does nothing. A programmer-defined constructor that takes no
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
parameters is also called a default constructor.
QUESTION 197
Given the code fragment?
arr = t.subArray(arr,0,2);
Which method can be inserted at line // insert code here to enable the code to compile?
Real 156
Oracle 1z0-803 Exam
A. public int[] subArray(int[] src, int start, int end) { return src;
}
B. public int subArray(int src, int start, int end) {
return src;
}
C. public int[] subArray(int src, int start, int end) { return src;
}
D. public int subArray(int[] src, int start, int end) { return src;
}
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
QUESTION 198
Given:
int x;
int y;
this.x = x;
y =this.y;
m1.x = 100;
m1.y = 200;
Real 157
Oracle 1z0-803 Exam
TestField m2 = new TestField();
m2.doStuff(m1.x, m1.y);
m1.display();
m2.display();
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
What is the result?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 199
Given:
package p1;
System.out.println(ref);
System.out.println(dvalue);
Real 158
Oracle 1z0-803 Exam
A. p1.Test.class
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
0.0
B. <the summary address refrenced by ref>
0.000000
C. Null
0.0
D. Compilation fails
E. A NullPointerException is thrown at runtime
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation: null
0.0
QUESTION 200
Given:
private int i;
void disp() {
while (i <= 5) {
i++;
i++;
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
new Natural().disp();
Real 159
Oracle 1z0-803 Exam
What is the result?
A. Prints 1 2 3 4 5 once
B. Prints 1 3 5 once
C. Prints 1 2 3 4 5 five times
D. Prints 1 2 3 4 5 six times
E. Compilation fails
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation: 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
QUESTION 201
Given:
do {
if (count >= 7) {
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
bVar1 = false;
count -= 2;
A. Hello Java! 8
Real 160
Oracle 1z0-803 Exam
Hello Java! 6
Hello Java! 4
B. Hello Java! 8
Hello Java! 6
C. Hello Java! 8
D. Compilation fails
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation: Hello Java! 8
QUESTION 202
Given the code fragment:
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
System.out.println((2 + 4 * 9) - 3); // Line 25
A. Line 21
B. Line 22
C. Line 23
D. Line 24
E. Line 25
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation: The following is printed:
Real 161
Oracle 1z0-803 Exam
QUESTION 203
Given:
class Base {
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
And the commands:
javac Sub.java
java Sub 10 20 30
A. Base 30
B. Overridden 20
C. Overridden 20
Base 30
D. Base 30
Overridden 20
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 204
Given:
Real 162
Oracle 1z0-803 Exam
interface Pet { }
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Correct Answer: ADE
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Incorrect:
Not B, not C: Pet is abstact, cannot be instantiated. Not F: incompatible type. Required Beagle, found Dog.
QUESTION 205
Given the code fragment:
arr[0][0] = 1;
arr[0][1] = 2;
arr[0][2] = 3;
arr[1][0] = 10;
arr[1][1] = 20;
arr[1][2] = 30;
Real 163
Oracle 1z0-803 Exam
arr[1][3] = 40;
Which two statements, when inserted independently at line // insert code here, enable the code to compile?
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
F. int [] [] arr = new int [0] [4];
Correct Answer: CE
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 206
Given:
int aw = 1, ay = 1;
try {
aw = ax % 2;
ay = az / aw;
System.out.println("Invalid Divisor");
aw = 1;
System.out.println("Divisor Changed");
ay = az /aw; // Line 14
Real 164
Oracle 1z0-803 Exam
System.out.println("Succesful Division " + ay);
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
}
A. Invalid Divisor
Divisor Changed
Successful Division 30
B. Invalid Divisor
Successful Division 30
C. Invalid Divisor
Exception in thread "main" java.lang.ArithmeticException: / by zero at test.Teagle.main(Teagle.java:14)
D. Invalid Divisor
Exception in thread "main" java.lang.ArithmeticException: / by zero at test.Teagle.main(Teagle.java:14)
Successful Division 1
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 207
Given the code fragment:
int count = 0;
if (ii == jj) {
++count;
break;
Real 165
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Oracle 1z0-803 Exam
}
System.out.print(count);
continue;
A. 011
B. 012
C. 123
D. 000
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 208
Given the code fragment:
class Student {
int rollnumber;
String name;
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
And,
Real 166
Oracle 1z0-803 Exam
public static void main(String[] args) {
List cs = newArrayList();
cs.add("Java");
cs.add("C");
System.out.println(s);
Which code fragment, when inserted at line // insert code here, enables class Test to print 123 :
Fred : [Java, C]?
Correct Answer: C
Section: (none)
Explanation
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Explanation/Reference:
Explanation:
Incorrect:
Not A: Student has private access line: Student s = new Student(123,"Fred", cs); Not D: Cannot be applied to given types. Line: Student s = new Student
(123,"Fred", cs);
QUESTION 209
Given the code fragment:
Real 167
Oracle 1z0-803 Exam
public class ForTest {
for ( foo ) {
Which three code fragments, when replaced individually for foo, enables the program to compile?
A. int i : array
B. int i = 0; i < 1;
C. ;;
D. ; i < 1; i++
E. i = 0; i<1;
Explanation/Reference:
Explanation:
QUESTION 210
Given:
abstract class A1 {
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
public abstract void m1();
Real 168
Oracle 1z0-803 Exam
public void m1() { System.out.println("Yellow"); }
A2 tp = new A3();
tp.m1();
tp.m2();
tp.m3();
A. Yellow
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Pink
Red
B. Cyan
Blue
Red
C. Cyan
Green
Red
D. Compilation Fails
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation: Yellow
Pink
Red
QUESTION 211
Which two statements correctly describe checked exception?
A. These are exceptional conditions that a well-written application should anticipate and recover from.
B. These are exceptional conditions that are external to the application, and that the application Real 169
Oracle 1z0-803 Exam
usually cannot anticipate or recover from.
C. These are exceptional conditions that are internal to the application, and that the application usually cannot anticipate or recover from.
D. Every class that is a subclass of RuntimeException and Error is categorized as checked exception.
E. Every class that is a subclass of Exception, excluding RuntimeException and its subclasses, is categorized as checked exception.
Correct Answer: BD
Section: (none)
Explanation
Explanation/Reference:
Explanation: Checked exceptions:
* (B) represent invalid conditions in areas outside the immediate control of the program (invalid user input, database problems, network outages, absent
files)
* are subclasses of Exception
It's somewhat confusing, but note as well that RuntimeException (unchecked) is itself a subclass of Exception (checked).
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
* a method is obliged to establish a policy for all checked exceptions thrown by its implementation (either pass the checked exception further up the
stack, or handle it somehow)
QUESTION 212
Given:
int count = 0;
if (count >= 4) {
break;
else {
continue;
Real 170
Oracle 1z0-803 Exam
}
if (c.length() >= 4) {
colors[count] = c.substring(0,3);
count++;
System.out.println(colors[count]);
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
}
A. Yellow
B. Maroon
C. Compilation fails
D. A StringIndexOutOfBoundsException is thrown at runtime.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation: The line, if (c.length() >= 4) {, is never reached. This causes a compilation error.
Note: The continue statement skips the current iteration of a for, while , or do-while loop. An unlabeled break statement terminates the innermost switch,
for, while, or do-while statement, but a labeled break terminates an outer statement.
QUESTION 213
Given:
Real 171
Oracle 1z0-803 Exam
Which two code fragments, when inserted independently at line // Insert code here, enable the program to execute and print the welcome message on
the screen?
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
D. public static void main (String [] args) {
E. public void main (String [] args) {
Correct Answer: AD
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Incorrect:
Not B: No main class found.
Not C: Main method not found
not E: Main method is not static.
QUESTION 214
Given the code fragment:
while ( <code1> ) {
if (arry[index-1] % 2 ==0) {
isChecked = true;
<code2>
System.out.print(arry(index]+", "+isChecked));
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
Real 172
Oracle 1z0-803 Exam
}
A. Replacing <code1> with index > 0 and replacing <code2> with index--;
B. Replacing <code1> with index > 0 and replacing <code2> with --index;
C. Replacing <code1> with index > 5 and replacing <code2> with --index ;
D. Replacing <code1> with index and replacing <code2> with --index ;
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Note: Code in B (code2 is --index;). also works fine.
QUESTION 215
Given:
int key = 3;
if (array[pos] == key) {
break;
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
}
Real 173
Oracle 1z0-803 Exam
A. Found 3 at 2
B. Found 3 at 3
C. Compilation fails
D. An exception is thrown at runtime
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation: The following line does not compile:
System.out.print("Found " + key + "at " + pos);
The variable pos is undefined at this line, as its scope is only valid in the for loop. Any variables created inside of a loop are LOCAL TO THE LOOP.
QUESTION 216
Given:
System.out.print(len);
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn
A. 8
B. 9
C. 11
D. 10
E. Compilation fails
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation: Java - String trim() Method
This method returns a copy of the string, with leading and trailing whitespace omitted.
Real 174
Oracle 1z0-803 Exam
Real 175
www.vceplus.com - Website designed to help IT pros advance their careers - Born to Learn