Given the code fragment:
interface SampleClosable {
public void close () throws java.io.IOException;
}
Which three implementations are valid?
Given:
And given the commands:
javac Test.java
java Test
What is the result?
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?
Given the code fragment:
Which option represents the state of the num array after successful completion of the outer loop?