1. The following Java code:
Public class Parent {
Public void function (){
System. out. println ("Father. function ");
}
}
Public class Child extends Parent {
Public void function (){
System. out. println ("Child. function ");
}
}
What is the result of executing the following programs? (Result: Child. function) Parent p = new Child ();
P. function (); Description: All functions in Java are virtual functions.
2. The following C code:
Class Parent {
Public: virtual void function (){
Cout <"Father. function ";
}
}
Class Child: public Parent {
Public: void function (){
Cout <"Child. function ";
}
}
What is the result of executing the following programs? (1) If there is no virtual keyword, the result is: Father. function (2) when the virtual keyword exists, the result is: Child. function (same as in Java) Parent p = new Child ();
P. function ();