Question 18
Not yet
answered
Flag
question
What will be the output of the following code?
class Parent {
String message = "Hello from Parent";
void displayMessage() {
System.out.println(message);
}
}
class Child extends Parent {
String message = "Hello from Child";
}
}
void displayMessage() {
System.out.println(message);
public class Main {
public static void main(String[] args) {
Parent p = new Child();
p.displayMessage();
}
}
O a. Hello from Child
O b. Hello from Parent
○ c.
Runtime error
O d. Compilation error