Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

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
Question ajoutée par Mohammed Abdul Mateen
Date de publication: 2013/10/31
Mahmoud Ebeed
par Mahmoud Ebeed , Senior Software Developer , Omnivista Solutions

first line11

second line11

Ajith Fernandez
par Ajith Fernandez , Software Engineer , Nayasoft Solutions Pvt.ltd

O/p first line :10

O/P Second line :10

 

sreerag arimbrathodiyil
par 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
par 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.

More Questions Like This

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?