Question: 1 . Create a class Student and another class Instructor. [ Details areunimportant at this stage, and yes, this will be very poor O -

1. Create a class Student and another class Instructor. [Details areunimportant at this stage, and yes, this will be very poor O-Odesign!]. Let each class have a single instance variable name thatcontains a full name. Class Student is shown at right. [Remember touse Eclipse source shortcuts to create these classes very quickly!]Suppose we want to require a behavior that displays a role as part ofthe name. For example:Stephen Weissman, instructorSusan Holly, student2. Create an interface RoleDisplayable to require a void method displayNameAndRole()a. Code a default method for displayNameAndRole() that makes all Student instances displaythe name with , Student after the name.b. Important: if its not a Student, lets make the default method do nothing. [Maybe notgreat design, but it will make this lab more interesting!] How will you do this??c. Also important: if you try to invoke getName() from your default method, youll get acompile error! [Remember static and dynamic types? getName() is in the dynamic typeStudent!] To solve this problem, well need to add a cast before thedot and method call something like this: ((Student) this).2. Make class Student implement RoleDisplayable.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!