Queenempress9412 Queenempress9412
  • 20-09-2019
  • Computers and Technology
contestada

Give the output of the following program: public class Example { public static void main(String [] args) { int x =5; int y =0; y = x++; System.out.print(y); System.out.print(x); } }

Respuesta :

SerenaBochenek SerenaBochenek
  • 23-09-2019

Answer:

Output of the following program is :56

Explanation:

In the given code snippet, x is initialize with 5 and y is with 0.Then  y=x++ statement will assign 5 to y and the increment the value of x,because x++ is a post increment operator.So the value of x will increase after this  statement.First print statement will print the value of y i.e 5 and the next print statement will print the value of x i.e 6 without space.Therefore the Output will be 56.

Answer Link

Otras preguntas

What rock is formed by metamorphosing shale? A. Basalt B. Granite C. Sandstone D. Slate
What is the total mass,in kilograms,of the 7rocks
In North Africa and Southwest Asia, the economies of many nations rely heavily on this natural resource. fertile soil
Which shows how the distributive property can be used to evaluate 7×84/5?
Agar is used to culture bacteria and as a medium in electrophoresis. The agar used in this Petri dish is a by-product of an unlikely organism. Agar is extracted
a dog pen measures 4 meters wide and has an area of 20 square meters. what is the perimeter of the pen in meters
Which collection of novels by James Fenimore Cooper is considered to be his greatest achievement? A. The Leatherstocking Tales. B. The Sea Novels. C. The Histor
Help from anyone please
In what population may the shock sign of clammy skin be absent?
What are the values of a and b?