Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

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 added by Mohammed Abdul Mateen
Date Posted: 2013/10/31
Mahmoud Ebeed
by Mahmoud Ebeed , Senior Software Developer , Omnivista Solutions

first line11

second line11

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

O/p first line :10

O/P Second line :10

 

sreerag arimbrathodiyil
by 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
by 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

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.