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:
Verified
Q1: Consider the classes shown below: public class
Q3: Consider the following inheritance hierarchy diagram:
Q4: A class that represents a more specific
Q5: Consider the hierarchy of classes shown below.
Q6: Which of the following statements about inheritance
Q7: Consider the following inheritance hierarchy diagram:
Q8: Consider the classes shown below: public class
Q9: Suppose the class Value is partially defined
Q11: Consider the classes shown below: public class
Q14: All rodents are mammals and all canines
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents