Free Oracle 1Z0-808 Exam Braindumps (page: 9)

Given the code fragment:

  1. Option A
  2. Option B
  3. Option C
  4. Option D
  5. Option E

Answer(s): A,C

Explanation:

Add throws clause in both printFileContent and main.



A method is declared to take three arguments. A program calls this method and passes only two arguments.
What is the results?

  1. Compilation fails.
  2. The third argument is given the value null.
  3. The third argument is given the value void.
  4. The third argument is given the value zero.
  5. The third argument is given the appropriate falsy value for its declared type.
  6. An exception occurs when the method attempts to access the third argument.

Answer(s): A



Which two actions will improve the encapsulation of a class?

  1. Changing the access modifier of a field from public to private
  2. Removing the public modifier from a class declaration
  3. Changing the return type of a method to void
  4. Returning a copy of the contents of an array or ArrayList instead of a direct reference

Answer(s): A,D


Reference:

http://www.tutorialspoint.com/java/java_access_modifiers.htm



Given:

public class ComputeSum {
public int x;
public int y;
public int sum;
public ComputeSum (int nx, int ny) {
x = nx; y =ny;
updateSum();
}
public void setX(int nx) { x = nx; updateSum();}
public void setY(int ny) { x = ny; updateSum();}
void updateSum() { sum = x + y;}
}
This class needs to protect an invariant on the sum field.
Which three members must have the private access modifier to ensure that this invariant is maintained?

  1. The x field
  2. The y field
  3. The sum field
  4. The ComputerSum ( ) constructor
  5. The setX ( ) method
  6. The setY ( ) method

Answer(s): C,E,F

Explanation:

The sum field and the two methods (setX and SetY) that updates the sum field.



Viewing page 9 of 60
Viewing questions 33 - 36 out of 245 questions



Post your Comments and Discuss Oracle 1Z0-808 exam prep with other Community members:

1Z0-808 Exam Discussions & Posts