This topic contains a solution. Click here to go to the answer

Author Question: What is y displayed in the following code?public class Test1 { public static void main(String[] ... (Read 73 times)

folubunmi

  • Hero Member
  • *****
  • Posts: 524
What is y displayed in the following code?

public class Test1 {
public static void main(String[] args) {
int x = 1;
int y = x = x + 1;
System.out.println("y is " + y);
}
}

◦ y is 0.
◦ y is 2 because x + 1 is assigned to x and then x is assigned to y.
◦ The program has a compile error since x is redeclared in the statement int y = x = x + 1.
◦ y is 1 because x is assigned to y first.


Related Topics

Need homework help now?

Ask unlimited questions for free

Ask a Question
Marked as best answer by folubunmi on May 6, 2020

Loise Hard

  • Sr. Member
  • ****
  • Posts: 340
Lorsum iprem. Lorsus sur ipci. Lorsem sur iprem. Lorsum sur ipdi, lorsem sur ipci. Lorsum sur iprium, valum sur ipci et, vala sur ipci. Lorsem sur ipci, lorsa sur iprem. Valus sur ipdi. Lorsus sur iprium nunc, valem sur iprium. Valem sur ipdi. Lorsa sur iprium. Lorsum sur iprium. Valem sur ipdi. Vala sur ipdi nunc, valem sur ipdi, valum sur ipdi, lorsem sur ipdi, vala sur ipdi. Valem sur iprem nunc, lorsa sur iprium. Valum sur ipdi et, lorsus sur ipci. Valem sur iprem. Valem sur ipci. Lorsa sur iprium. Lorsem sur ipci, valus sur iprem. Lorsem sur iprem nunc, valus sur iprium.
Answer Preview
Only 39% of students answer this correctly




folubunmi

  • Member
  • Posts: 524
Reply 2 on: May 6, 2020
:D TYSM


ryansturges

  • Member
  • Posts: 338
Reply 3 on: Yesterday
Gracias!

 

Did you know?

Blastomycosis is often misdiagnosed, resulting in tragic outcomes. It is caused by a fungus living in moist soil, in wooded areas of the United States and Canada. If inhaled, the fungus can cause mild breathing problems that may worsen and cause serious illness and even death.

Did you know?

One way to reduce acid reflux is to lose two or three pounds. Most people lose weight in the belly area first when they increase exercise, meaning that heartburn can be reduced quickly by this method.

Did you know?

Critical care patients are twice as likely to receive the wrong medication. Of these errors, 20% are life-threatening, and 42% require additional life-sustaining treatments.

Did you know?

Essential fatty acids have been shown to be effective against ulcers, asthma, dental cavities, and skin disorders such as acne.

Did you know?

The top 10 most important tips that will help you grow old gracefully include (1) quit smoking, (2) keep your weight down, (3) take supplements, (4) skip a meal each day or fast 1 day per week, (5) get a pet, (6) get medical help for chronic pain, (7) walk regularly, (8) reduce arguments, (9) put live plants in your living space, and (10) do some weight training.

For a complete list of videos, visit our video library