ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

Dry run this java prog ? and give the result

public static void main(String []args){ Integer i=new Integer(128); int e=128; if(i==e){ System.out.println("Hello World" ); } else { System.out.println("no problem"); } }

user-image
تم إضافة السؤال من قبل Mohd shahnawaz khan , Associate Project , Cognizant Technology Solution
تاريخ النشر: 2013/12/26
Preetham D
من قبل Preetham D , Software Engineer / Senior Software Engineer , Mindtree

O/P: Hello World

Shabeer Mohamed Muthachodi
من قبل Shabeer Mohamed Muthachodi

 

1) We would be able to compile it only if you put this code inside a valid class .

2) As others mentioned, when you run it it will print "Hello World".

 

3) We may also use i.equals(e) instead of i==e

4) We cannot use e.equals(i) , however we can use e==i

 

Mr. Shahnawaz, any particular reason for this question/ is the answer "Hello World" is wrong ?

 

Thanks

 

 

 

Daanish Rumani
من قبل Daanish Rumani , Product Manager , Publicis Sapient

Answer: no problem

 

i.equals(e) should have been used

Ankur Pandey
من قبل Ankur Pandey

ofcourse "Hello World"  becoz reference ID128 is passed into variable i .

Usman Liaqat
من قبل Usman Liaqat , Principal Software Engineer , Soliton Technologies

Is it to gain the points only ?

Ofcourse : Hello World

Md. Kaium Hossain
من قبل Md. Kaium Hossain , Assistant Programmer , ERA Info Tech Ltd.

Answer: Hello World

المزيد من الأسئلة المماثلة