Solved

Suppose the Class Message Is Partially Defined as Shown Below

Question 9

Multiple Choice

Suppose the class Message is partially defined as shown below public class Message
{
Private String value;
Public Message(String initial)
{
Value = initial;
}
Public String getMessage()
{
Return value;
}
}
A subclass of Message, ExcitedMessage, is defined that will behave like Message, except that it will add two exclamation points to the end of the message. Sample code that uses ExcitedMessage is shown below.
ExcitedMessage greeting = new ExcitedMessage("Hello") ;
System.out.print(greeting.getMessage() ) ;
// will print "Hello!!"
Which ExcitedMessage constructor will give this behavior?


A) public ExcitedMessage(String line) {
Super(line + "!!") ;
}
B) public ExcitedMessage(String line) {
Value = line + "!!";
}
C) public ExcitedMessage(String line) {
Line = line + "!!";
Super(line) ;
}
D) public ExcitedMessage(String line) {
New Message(line + "!!") ;
}

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions