Details of this Paper

Week 7 In this set of assignments you will exercise




Week 7 HA - yes_no;In this set of assignments you will exercise the object-oriented concepts of inheritance and polymorphism. Both questions are required.;This question is to be answered on ?paper?. Please type your answer to each subpart into a word document (week7-q1.doc) and submit.;Consider the following definitions of classes.;public class Pet { };public class Robot extends Pet;public boolean strongerThan(Robot other) {...}...;public class HousePet extends Pet;public String vetsName() {...};public class Dog extends HousePet;public Object fetch() {}...;Note that in the code above the... indicates where there may be extra code which hasn't been shown.;Given the following variable definitions;Pet pet;HousePet housepet;Dog dog;Robot robot;Indicate below which one of the following code snippets are legal and which are not legal by writing yes or no next to each code snippet. View each snippet in isolation (independent of other code snippets).;a. pet = dog;b. dog = housepet;c. housepet = (Dog) robot;d. housepet.fetch();e. ((Dog) pet).fetch();f. robot.strongerThan(pet);g. robot.strongerThan((Robot) pet);h. dog.vetsName()


Paper#69021 | Written in 18-Jul-2015

Price : $32