RUVIDEO
Поделитесь видео 🙏

Conceptual & Tricky Interview Question on String in JAVA | Important Q/A for 2019 Java Developer

📁 Обучение 👁️ 17 📅 05.12.2023

Conceptual & Tricky Interview Question on String in JAVA | Important Q/A for 2019 Java Developer

String s1 = "TechTalk";
String s2 = "TechTalk";

How many Objects will be created in Java ?
In this case one Objects will be created, as we are creating String with the help of String Literals.
So Both content is same and JVM will not create same String in the "String constant pool".
JVM will return same reference to the next variable , here S2. hence only one Object will be created.
Please note: if we change the word case from small to upper, then two objects will be creaed , as it is a case sensitive.


String s1 =new ("TechTalk");
String s2 =new ("TechTalk");

In that case two objects will be created, as it will create on heap area and it's does not depend on the content of the Object.

public class TrickyQuestionOnString {

public static void main(String[] args) {

String s1 = "TechTalk";
String s2 = "TechTalk";
System.out.println(s1 == s2);


// We can check the different object with this value
System.out.println(s1.hashCode());
System.out.println(s2.hashCode());

String s3 = "Techtalk";

System.out.println(s3 == s1);

String s4 = new String("TechTalk");
String s5 = new String("TechTalk");

// We can check the different object with this value
System.out.println(s4.hashCode());
System.out.println(s5.hashCode());
}

}
#For #Core #Java #Interview #Program
#GitHub #Code #Link https://github.com/admindebu/Core-Java-Interview-Program

Follow me on FaceBook: https://www.facebook.com/TechTalkDebu
Instagram: techtalk_debu
and LinkedIn : https://www.linkedin.com/in/debu-paul

if you like my video, please subscribe to my channel and share the video

Thanks & Regards,
Debu Paul

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Conceptual & Tricky Interview Question on String in JAVA | Important Q/A for 2019 Java Developer», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.