The protected explanation is incorrect. Enemy and Ghost didn't have to be in the same package. Ghost could have accessed the protected name filed as long as it extends Enemy class. Your example would be correct with default modifier which is package-private.
Good job on this one! It would be great to see an advanced/intermediate JAVA interview questions.
This example would be better in explaining deep copy(constructor method): public Example(Example original) { this.x= original.x; } Example example2 = new Example(example1); example2.x = 200; sout(example1.x);
You didn’t explain what is deep copy, you just crated a new object. But what if I want to create exactly the same copy of existing instance?
8:00 this doesn't really explain what shallow and deep copies are. It's not a deep copy if you just create a new object and populate it manually. The default implementation of clone() on Object creates a new instance of that class with new references to the same referenced object fields of the original - this is a shallow copy. You can override clone() to create a deep copy by creating new referenced object fields. This way if anything changes in the referenced object fields it is only reflected in the new deep copy, not the original.
We need a whole series on these
I was a c# dev for 5 years but I’m interviewing for a Java position today. Thanks for the refresher!
great job on this one - just noticed a slight nuance to observe. I think the default access modifier Eg no modifier will allow other classes inside the package to access the variables/methods but protected will only allow child classes which extends their parent class to access those variables/methods which are protected.
This was an amazing recap, thank you very much
Thank you so much for sharing the valuable knowledge. I'm junior and I learned many thing from your video. Good job. It'd be great for junior developer
Seems like a great interview. I usually make similar questions to juniors. The problem comes with companies that basically make juniors grind leetcode like monkyes :_(
Paused at 1:01 and glad to know I would pass the Jr. Java coding interview 😂
Please make a video of some more advanced questions...Very Good work
WOW!!! short and simple..first time on this channel and impressed!!!
Thanks a lot Sam, I am having my technical interview for Internship this week, and your video is so helpful, fingers crossed
I have an upcoming interview and your explainations is so good.
more videos like this please, I love it, thankyou!
the "has a" example being a person has a job is such a roast on a video meant for interviews
This is so easy, once I have applied to EPAM for Junior Position, their test was like 1500 times harder
@KeepOnCoding