tg-me.com/topJavaQuizExplain/99
Last Update:
What is the output of the code?
❌ A. Orca diving
✅ B. The code will not compile because of line 2
❌ C. The code will not compile because of line 8
❌ D. The code will not compile because of line 9
❌ E. The output cannot be determined from the code provided
Explanation:
This may look like a complex question, but it is actually quite easy. Line 2 contains an invalid definition of an abstract method. Abstract methods cannot contain a body, so the code will not compile and option B is the correct answer. If the body {} was removed from line 2, the code would still not compile, although it would be line 8 that would throw the compilation error. Since dive() in Whale is abstract and Orca extends Whale, then it must implement an overridden version of dive(). The method on line 9 is an overloaded version of dive(), not an overridden version, so Orca is an invalid subclass and will not compile.
BY Explanations “Top Java Quiz Questions”
Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283
Share with your friend now:
tg-me.com/topJavaQuizExplain/99