Q1. Identify two benefits of using ArrayList over array in software development.
A. reduces memory footprint
B. implements the Collection API
C. is multi.thread safe
D. dynamically resizes based on the number of elements in the list
Answer: AD
Q2. Which two are valid instantiations and initializations of a multi dimensional array?
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
Answer: BD
Q3. Given:
Class A { }
Class B { }
Interface X { }
Interface Y { }
Which two definitions of class C are valid?
A. Class C extends A implements X { }
B. Class C implements Y extends B { }
C. Class C extends A, B { }
D. Class C implements X, Y extends B { }
E. Class C extends B implements X, Y { }
Answer: AE
Q4. Given:
What is the result?
A. The sum is 2
B. The sum is 14
C. The sum is 15
D. The loop executes infinite times
E. Compilation fails
Answer: D
Q5. Given:
Which two classes use the shape class correctly?
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
F. Option F
Answer: BE
Q6. Given:
What is the result?
A. One
B. Two
C. Three
D. Compilation fails
Answer: D
Q7. View the exhibit.
Given the code fragment:
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,
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}
Answer: C
Q8. View the Exhibit.
public class Hat {
public int ID =0;
public String name = "hat";
public String size = "One Size Fit All";
public String color="";
public String getName() { return name; }
public void setName(String name) {
this.name = name;
}
}
Given
public class TestHat {
public static void main(String[] args) {
Hat blackCowboyHat = new Hat();
}
}
Which statement sets the name of the Hat instance?
A. blackCowboyHat.setName = "Cowboy Hat";
B. setName("Cowboy Hat");
C. Hat.setName("Cowboy Hat");
D. blackCowboyHat.setName("Cowboy Hat");
Answer: D
Q9. Given the code fragment:
int b = 3;
Oracle 1z0-803 : Practice Test
if ( !(b > 3)) {
System.out.println("square ");
}{
System.out.println("circle ");
}
System.out.println("...");
What is the result?
A. square...
B. circle...
C. squarecircle...
D. Compilation fails.
Answer: C
Q10. Given:
What three modifications are necessary to ensure that the class is being properly encapsulated?
This class is poorly encapsulated. You need to change the circle class to compute and return the area instead.
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;
}
Answer: BCD