Answer the question
In order to leave comments, you need to log in
How many objects are created in the code?
I came across one topic here, and I was interested in the question asked at the interview to the author (I quote):
Even at the dawn of my career, I tried to squeeze into one company, they bombarded me with questions in the spirit of "how many objects are there" at the interview:String v1 = "Text"; String v2 = v1; System.out.println(v2);
Answer the question
In order to leave comments, you need to log in
Один. v2
- ссылка на тот же самый объект, на который ссылается v1
.
Смотря что задающий вопрос имеет ввиду говоря "здесь".
В коде описано взаимодействие двух объектов: объекта "Text" и объекта System.out.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question