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:

Verified
Correct Answer:
Verified
Q4: Consider the following class hierarchy: public class
Q5: Consider the following code snippet: public class
Q6: Which of the following indicates that the
Q7: Consider the following code snippet: public class
Q8: Consider the classes shown below: public class
Q10: Consider the following code snippet: Vehicle aVehicle
Q11: Consider the following code snippet: public class
Q12: Consider the following code snippet: public class
Q14: Consider the following code snippet: Employee programmer
Q74: All rodents are mammals and all canines