An initialization issue
No. 223
|
Q: |
We consider a class representing book instances containing a compiler error in line 3: 01 public class Book {
02
03 final int numberOfPages; // Error: Variable 'numberOfPages'
04 //might not have been initialized
05 String title;
06
07 public Book(final String title, final int numberOfPages) {
08 this.numberOfPages = numberOfPages;
09 this.title = title;
10 }
11
12 public Book() {}
13 }Answer the following questions:
TipConsider the default constructor's role. |
|
A: |
Having two constructors
The three answers thus are:
|
