What is the result of the following program?
1: public abstract class Message { 2: public String recipient; 3: public abstract final void sendMessage(); 4: public static void main(String[] args) { 5: Message m = new TextMessage(); 6: m.recipient = "1234567890"; 7: m.sendMessage(); // w w w. j av a 2 s. c o m 8: } 9: static class TextMessage extends Message { 10: public final void sendMessage() { 11: System.out.println("Text message to " + recipient); 12: } 13: } 14: }
D.
The code does not compile because a method is not allowed to be both abstract and final.
If final were removed, the answer would be B.
An abstract class may contain an abstract method.
A static nested class may extend other classes.