public class Account {
private double balance;
public Account(double b) { balance = b; }
}
// ...
Account a = new Account(100.0);
System.out.println(a.balance);What is the result?
- A
Run-time error
- B
100.0
- C
0.0
- Dcheck_circle
Compile-time error: balance has private access
Explanation
The instance variable balance is declared private, so it cannot be accessed from outside the class.