Question: 1. Suppose you have an interface called ShakesHands with the following method listed in that interface: public void shakeHands (ShakesHands other); and three classes

1. Suppose you have an interface called ShakesHands with the following method listed in that interface: public void shakeHands (ShakesHands other); and three classes (Student, Teacher, Parent) all of which implement the ShakesHands interface, determine which of the following code fragments would compile: ShakesHands x = new ShakesHands(); ShakesHands x = new Student(); Student x = new ShakesHands(); Student x = new Teacher(); ShakesHands x; x = new Student(); x = new Teacher(); x = new Parent(); Teacher x = new Teacher(); Teacher y = new Teacher(); x.shakeHands (y); Student x = new Student(); Teacher y = new Teacher(); x.shakeHands (y); Parent x = new Parent(); String y = new String("Parent"); x.shakeHands (y); ShakesHands x = new Student(); x.shakeHands (x);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
