public class T {
private int v;
public T(int x) { setV(x); }
public void setV(int x) { v = x * 2; }
public int getV() { return v; }
}
// ...
T t = new T(7);
System.out.println(t.getV());What is printed?
- A
Compile-time error
- B
7
- C
0
- Dcheck_circle
14
Explanation
The constructor calls setV(7) which sets v = 14.