CodeGym /Courses /Java Core /Polymorphism Tasks Polymorphism Tasks Java Core Level 2, Lesson 2 Available "Hello, Amigo! Here are a couple hundred tasks on polymorphism for you." "Huh? A hundred more exercises?!" "I'm joking. Just ten. I mean, five." 3 Task Java Core, level 2, lesson 2 Locked Whales and cows Whales and cows 3 Task Java Core, level 2, lesson 2 Locked Whales, the descendants of cows Whales, the descendants of cows 3 Task Java Core, level 2, lesson 2 Locked Render to Caesar the things that are Caesar's Render to Caesar the things that are Caesar's 3 Task Java Core, level 2, lesson 2 Locked Whether it's a bird or a lamp Whether it's a bird or a lamp 3 Task Java Core, level 2, lesson 2 Locked Animal identification Animal identification Comments (17) TO VIEW ALL COMMENTS OR TO MAKE A COMMENT, GO TO FULL VERSION Krzysztof Kosała Level 21, Wejherowo, Poland 10 April 2024 The last one: public static String getObjectType(Object o) { return o instanceof Cow || o instanceof Whale || o instanceof Dog ? o.getClass().getSimpleName():"Unknown Animal"; } Thomas Level 13, Scottsdale, United States 16 January 2024 I'm not a cow. I'm a whale. Alex Tor Level 31, Bulgaria 3 November 2022 an alternative way for 4th task: String result = o.getClass().getName().toString(); System.out.println(result.substring(result.indexOf("$")+1)); Ashish RajAnand Level 13, Bhilai , India 10 May 2020 I glad . Ruslan Skaldin Level 33, Tashkent, Uzbekistan 24 December 2019 It gives good explanation when we can use "instanceof" operator Alexandru Ovcinicov Level 15, London, United Kingdom 25 September 2019 Moving ye Renat Mukhametshin Level 16, Pervouralsk, Russain Federation 30 August 2019 it's not difficult yet, and i'm waiting a miniprojects as soon as can be it. holybible Level 28, Plovdiv, Bulgaria 26 August 2019 sweet moving on Krisztian Level 24, Budapest, Hungary 5 June 2019 If the task would be only 4, it could be a classic robot joke. you know, 100 in binary means 4. You get it? :D Hossein Shams Level 1, Atlanta, United States 15 July 2019 or maybe he could say he's got 101 tasks for us. hahaha Darko Jakimovski Level 18, Kriva Palanka, Macedonia, The Former Yugoslav Republic of 24 April 2019 God damn that improved my knowledge Load more comments
GO TO FULL VERSION