Understanding Chapter 2 Q 22 of A Little Java, A Few Patterns -


in chapter 2 of a little java, few patterns, question 22 is:

are there onions on shish^d:

new skewer()?

answer is:

true, because there neither lamb nor tomato on new skewer().

definitions of classes

skewer subclass of shish^d, onion subclass of shish^d, don't understand why there onions on new skewer(), explain bit further?

i've googled book , although pages missing, think question's about:

shish s = new skewer(); system.out.println(s.onlyonions()); //prints true; 

it prints true because onlyonions() declared abstract in super class shish , overriden in skewer class follows:

class skewer extends shish {       @override       boolean onlyonions(){         return true;       } } 

so should clear s.onlyonions() returns true, since s' dynamic type skewer.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -