Instructions: Answer the following questions one at a time. After answering each question, check your answer (by clicking on the check-mark icon if it is available) before proceeding to the next question.
Getting Ready: Before going any further, you should:
downloads directory/folder). In most browsers/OSs, the
easiest way to do this is by right-clicking/control-clicking on
each of the links above and then selecting Driver.
Driver, don't change the declaration of the
variable named doc but change the line containing
doc = new Document(text); to doc = new
String(text);.
Driver.
Driver, don't change the declaration of the
variable named doc but change the line that now
contains doc = new String(text); to doc = new
FormattedDocument(text);.
Driver.
FormattedDocument have
a constructor
with a single String parameter?
FormattedDocument class inherit
constructors from its parent?
Driver, Don't change the declaration of the
variable named doc but change the line that now
contains doc = new FormattedDocument(text);
to doc = new FormattedDocument(text, 20);.
Driver.
getDescription() and getText()
methods in the FormattedDocument class used even though
doc is declared to be a Document?
getText() method in the FormattedDocument
class contains the line temp = super.getText();. Explain
this line of code.
temp = super.getText(); in the
FormattedDocument class with the
line temp = getText();.
FormattedDocument and execute Driver.
Counter.java
Counter class.
public int i;
Counter.java
i so that it is now
private.
Counter.java
firstNonNull() method when it is called.
i.
firstNonNull()
method without making any other changes.
private int i;
Counter.java
firstNonNull() so that it works propery.
Counter.java to make sure you have didn't
make any syntax errors.
i from the for
statement (but leave the semi-colon).
Counter.java,
getDelimiters()
method in the Document class private.
Document class.
FormattedDocument class.
getDelimiters() method in the Document
class protected.
public version
and the protected version?
Which is better? Why?
getWordCount()
method.
delimiters and
text attributes in the Document class
to protected.
FormattedDocument class? (Hint: Think about how
the FormattedDocument class accesses these attributes.)
delimiters attribute is protected,
do you still need the getDelimiters() method?
getDescription() or
getText() methods in the Document
class be protected? Why or why not?
Copyright 2025