Let's initialize our first user under the name Neo. To do this, implement the DBObject interface and its initializeIdAndName method in the User class so that the program runs and displays "The user's name is Neo, id = 1".
Neo
- 8
Locked
Comments (11)
- Popular
- New
- Old
You must be signed in to leave a comment
Hoist
5 March, 04:11
Finally -- that took 1 year. The user's name is Neo, id = 1 ![]()

0
Karas Java Developer
21 November 2020, 01:13
The answer to this is... public. This little word placed correctly in the correct place solves a lot.
Litterally just follow the requirements.
Also the word static, if I am not wrong, this in itself allows a method to be called even if the instance has not been created, as it is being created at the same time. right? thus you can return this as the requirement requires.
0
yehuda b
20 May 2020, 17:31
How is can the User be instantiated? isn't it a static class? or maybe because it calls the initialize method right away, it is valid? but why?
+1
Andrew Evans
27 February 2022, 21:50
A static inner class can be instantiated without the need for an instance of the outer class. In general, an Inner class is a part of nested class, called Non-static nested classes in Java.
+1
IO.Error
19 February 2020, 22:15

+2
IO.Error
19 February 2020, 22:14
Can someone give some more details please ?
The user's name is Neo, id = 1
Neo is instance of DBObject : true
Neo is instance of User : true
getclass() returns Matrix.NEO : User
Process finished with exit code 0
If I change the return type to user I still get:
The user's name is Neo, id = 1
Neo is instance of DBObject : true
Neo is instance of User : true
getclass() returns Matrix.NEO : User
Process finished with exit code 0
I assume this is because :
public static DBObject NEO = new User().initializeIdAndName(1, "Neo");
I had to change the return type in the method initializeIdAndName for it to verify - ok.
But why do I have to change the return type in the first place ?
How can I verify in the code what's going on ? instanceof and getclass() don't seem to help ...
Thanks a lot
0
Roman
20 February 2020, 12:11
Please refer to Help section at our course.
0
Hoist
5 March, 04:12
HELP section discussion -- https://codegym.cc/help/7613
0
Muhammad Vahhaaj
28 July 2019, 17:25
How is this even a thing. In some lesson it was said that to override/implement a method its signature must be the same :-/
0
Asma Sadia
17 January 2020, 04:55
Yes. Can someone explain this?
0
Baurzhan Konurbayev
5 August 2020, 00:03
Seems like Interface and Class types are interchangeable, but doesn't explain why it still implements interface method with the different signature.
0