Oracle 1z0-803 Exam Practice Questions (P. 5)
- Full Access (216 questions)
- Six months of Premium Access
- Access to one million comments
- Seamless ChatGPT Integration
- Ability to download PDF files
- Anki Flashcard files for revision
- No Captcha & No AdSense
- Advanced Exam Configuration
Question #21
Given:

Which three lines will compile and output "right on!"?

Which three lines will compile and output "right on!"?
send
light_mode
delete
Question #22
Given the code fragment:
String h1 = "Bob";
String h2 = new String ("Bob");
What is the best way to test that the values of h1 and h2 are the same?
String h1 = "Bob";
String h2 = new String ("Bob");
What is the best way to test that the values of h1 and h2 are the same?
- Aif (h1 = = h2)
- Bif (h1.equals(h2))
- Cif (h1 = = h2)
- Dif (h1.same(h2))
Correct Answer:
B
The equals method compares values for equality.
Incorrect answers:
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 compares values for equality.
There is no generic comparison method named same.
= = (with a space) is not a valid method.
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.
B
The equals method compares values for equality.
Incorrect answers:
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 compares values for equality.
There is no generic comparison method named same.
= = (with a space) is not a valid method.
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.
send
light_mode
delete
Question #23
Which two are valid declarations of a two-dimensional array?
- Aint [] [] array2D;
- Bint [2] [2] array2D;
- Cint array2D [];
- Dint [] array2D [];
- Eint [] [] array2D [];
Correct Answer:
AD
int[][] array2D; is the standard convention to declare a 2-dimensional integer array. int[] array2D[]; works as well, but it is not recommended.
Incorrect answers:
int[2][2] array2D;
The size of the array cannot be defined this way.
int array2D[]; is good definition of a one-dimensional array. int[] []array2D[];is good definition of a three-dimensional array.
AD
int[][] array2D; is the standard convention to declare a 2-dimensional integer array. int[] array2D[]; works as well, but it is not recommended.
Incorrect answers:
int[2][2] array2D;
The size of the array cannot be defined this way.
int array2D[]; is good definition of a one-dimensional array. int[] []array2D[];is good definition of a three-dimensional array.
send
light_mode
delete
Question #24
Given the code fragment:
System.out.printIn ("Result: " +3+5);
System.out.printIn ("Result: " + (3+5));
What is the result?
System.out.printIn ("Result: " +3+5);
System.out.printIn ("Result: " + (3+5));
What is the result?
- AResult: 8 Result: 8
- BResult: 35 Result: 8
- CResult: 8 Result: 35
- DResult: 35
Correct Answer:
B
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.
B
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.
send
light_mode
delete
Question #25
Given:

Which two are possible outputs?


Which two are possible outputs?

- AOption A
- BOption B
- COption C
- DOption D
Correct Answer:
AD
The first println statement, System.out.println("Before if clause");, will always run.
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.
Incorrect answers:
B: The second println statement would not run.
C: The first println statement will always run.
AD
The first println statement, System.out.println("Before if clause");, will always run.
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.
Incorrect answers:
B: The second println statement would not run.
C: The first println statement will always run.
send
light_mode
delete
All Pages