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

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

متابعة

What is the output? class A { public static void main(String args[]) { int i=10; i=i++; System.out.println(i); System.out.println(i); } }

user-image
تم إضافة السؤال من قبل Mohammed Abdul Mateen
تاريخ النشر: 2013/10/31
Mahmoud Ebeed
من قبل Mahmoud Ebeed , Senior Software Developer , Omnivista Solutions

first line11

second line11

Ajith Fernandez
من قبل Ajith Fernandez , Software Engineer , Nayasoft Solutions Pvt.ltd

O/p first line :10

O/P Second line :10

 

sreerag arimbrathodiyil
من قبل sreerag arimbrathodiyil , Software Developer , SystechInfovations

The answer should be10

because here 

int i=10;

i=i++;

here the i value remain same and it is not a loop (value will be changed based on the loop)

 

if i=++i in this situation the value become  i=11

 

Allah bakash Shaik
من قبل Allah bakash Shaik , Team member , Altisource Business Solutions Pvt Ltd

first: i=10;

second: i=10;

because here using post increment,thats why it uses next usage only.

here i using next level only,we are not insitialisation to another varaible.

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