Solved

Suppose the Class Message Is Partially Defined as Shown Below

Question 2

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

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents