Respuesta :
The following exercise is about spotting which program or code fragment would compile and that which would not.
What is a code fragment?
A code fragment is a minor or irrelevant section of the source code (determined in relation to the functionality of the Work Product as a whole).
In order to provide a product that is functionally identical to the Work Product including such Code Fragments, the Service Provider will not mix Code Fragments.
What does it mean to compile?
When a piece of code is compiled, it signifies that it has been transformed into machine code or another lower-level form that allows the program to run.
Which fragments will compile?
ShakeHands x = new ShakeHands();
This won't compile because there was no instantiation of the Interfaces.
ShakeHands x = new Student();
Because this is a valid and legal statement, it will definitely compile.
Student x = new ShakeHands();
This will not compile. The reason is that Student and Teacher are two different objects. The only thing these two classes have in common is that they both implement the ShakeHands interface, but even then, unless Student and Teacher are parent/child classes, they cannot be paired up.
ShakeHands x;
x=new Student();
x=new Teacher();
x=new Parent();
All of the aforementioned claims are true since they are all lawful. Since the ShakeHands interface is implemented by the Student, Teacher, and Parent classes, any child class's objects may be initialized using the ShakeHands class reference or object.
It is to be noted that can access only shakeHands() method defined in ShakeHands interface.
Learn more about compiling at;
https://brainly.com/question/25823499
#SPJ1
