What will be the output of the following program?
public class KeepItClean {
public static void main(String[] args) {
Valuable.status();
try(Valuable v = new Valuable(); Valuable v2 = new Valuable())
{
Valuable.status();
v.open();
Valuable.status();
v2.open();
Valuable.status();
}
Valuable.status();
}
}
class Valuable implements AutoCloseable {
static int numberOfValuables = 5;
Valuable() {
open();
}
public void open() {
numberOfValuables--;
System.out.print("O" + numberOfValuables + " ");
}
public void close() {
numberOfValuables++;
System.out.print("C" + numberOfValuables + " ");
}
static void status() {
System.out.print("S" + numberOfValuables + " ");
}
}