Question: Can you explain please? Also, what does parantheses mean, for example printName ((Parakeet) parrot1); Consider the following hierarchy of classes: A program is written to

Can you explain please? Also, what does parantheses mean, for example printName ((Parakeet) parrot1);
Consider the following hierarchy of classes: A program is written to print data about various birds: public Class Birdstuff { public static void printName (Bird b) { / * implementation not shown */ } public static void prinBirdCall(Parrot p) { /* implementation not shown */ } //several more Bird methods public static void main (String [] args) { Bird bird1 = new Bird(); Bird bird2 = new Parrot(); Parrot parrot1 = new Parrot (); Parrot parrot2 = new Parakeet(); /* more code */ } } Assuming that none of the given classes is abstract and all have default constructors, which of the following segments of /* more code */ will not cause an error? (A) printName(parrot2); printBirdCall((Parrot) bird2); (B) printName((Parrot) bird1); printBirdCall(bird2); (C) printName(bird2); printBirdCall(bird2); (D) printName ((Parakeet) parrot1); printBirdCall(parrot2); (E) printName((Owl) parrot2); printBirdCall ((Parakeet) parrot2)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
