CodeGym /Courses /Java Multithreading /Practice inheriting nested classes

Practice inheriting nested classes

Java Multithreading
Level 4 , Lesson 4
Available

"Hi, Amigo!"

"Here's a spiffy set of tasks for you. I hope you like them:"

13
Task
Java Multithreading, level 4, lesson 4
Locked
Refactoring Rectangle
In the Rectangle class: 1. Change the getHeight and getWidth methods so that they return HasHeight and HasWidth objects, respectively. 2. To do this, inside the getHeight and getWidth methods, create local classes that implement the interfaces.
26
Task
Java Multithreading, level 4, lesson 4
Locked
Black box
1. Repair the logic of the someAction method for the solutionAction field. 2. See the comment on the main method for example output. 3. Hint: if param > 0, then the someAction method of an anonymous class in the solutionAction field should call a method of the FirstClass subclass.
7
Task
Java Multithreading, level 4, lesson 4
Locked
Inheriting an inner class
Inside the Solution class, create 2 public inner classes: ThreeBedroomApt and BigHall. Make them inherit Apartment and Hall.
Comments (5)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
Jurij Thmsn Level 29, Flensburg, Germany
22 October 2021
Don't dig too deep into BlackBox, it's not worth it. There is so much else important to learn about java which is much more worth the time.
null Level 26, Orlando, United States
11 August 2020
BlackBox task is confusing. Need better explanation
Fadi Alsaidi Level 34, Carrollton, TX, USA
16 December 2020
It really was. I suggest debugging to follow along. Essentially the code makes the Solution's "someAction" go throw an if logic based on "param" number. The if logic either return a firstClass's "someAction" or return a Solution's "smartAction". since the parm starts with a 5, the if logic keeps returning the solutions calss"smartAction" which basically re-excute the same if logic ...so kinda like a loop where the firstclass method keeps calling back it's super calss's method "Solution" someActione until the "param" is less than 0...This loop I am talking about all happens in the "getDependantAction method which returns an Action Object. The action object either is the Solution's calss or the first class. .but really watching the debug go through it might help more espically around the "This" keyword which is kinda confusing with outer and inner classes
Henrique Level 41, São Paulo, Brazil
29 July 2020
My impression is that a lot of these tasks are deliberately confusing. On the first one, e.g., if we follow exactly the steps that Kim gave us on the last lesson, the code won't work (it won't even compile). So we'll have to search for the solution somewhere else, which makes the task not "easy" at all. There's a lack of explanation and exemples. Fortunately we have some people on the help session that already passed such tasks, so we can copy and paste their codes, hoping that one day we will find explanations and will understand the solutions.
Isma Level 41, Madrid, Spain
29 January 2021
Did that day come?