Evaluate the following Java expression, if x=3, y=5, and z=10: ++z + y – y + z + x++

A) 23 B) 22 C) 25 D)24

Have an account? Sign In Now

Don't have account, Sign Up Here

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Need An Account, Sign Up Here

Anonymous

Asked: 2021-09-06T13:18:38+05:30
2021-09-06T13:18:38+05:30In: Education and learning

Evaluate the following Java expression, if x=3, y=5, and z=10: ++z + y – y + z + x++

A) 23 B) 22 C) 25 D)24

Leave an answer

- Which of these classes are the direct subclasses of the Throwable class?
- Which of the following for loop declaration is not valid?
- Is Flutter likely to replace Java for Android app development?
- Should I learn Java or Kotlin in order to develop Android apps?
- Which are the frequently asked interview questions for Java Engineers ?
- Between Java and Python, which one is better to learn first and why?
- Which is better, Java or Python? And how?
- Why Java is not 100% Object-oriented programming language?

Answer : option C) 25.Explanation:

Values of variables: x=3, y=5, z=10

Given Expression:++z + y – y + z + x++

above expression ++z is pre increment by one value so ++z is 11, and x++ value is post increment value incremented by 1 but it will be stored in the next x value so x++ will be 3.

Exp=++z + y – y + z + x++

exp= 11+5-5+11+3= 25

hence the option

C) 25Value is correct.Answer: C) 25Explanation:

++z + y – y + z + x++ // Here ++z is preincrement so value is increment by 1.

11+5-5+11+3= 25

the correct answer is

25