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

Author Question: Suppose you enter 34.3 57.8 789, then press the ENTER key. Analyze the following code.Scanner input ... (Read 223 times)

pragya sharda

  • Hero Member
  • *****
  • Posts: 566

Question 1

Which method can be used to create an input object for file temp.txt?
◦ new Scanner("temp.txt")
◦ new Scanner(File("temp.txt"))
◦ new Scanner(new File("temp.txt"))
◦ new Scanner(temp.txt)

Question 2

Suppose you enter 34.3 57.8 789, then press the ENTER key. Analyze the following code.

Scanner input = new Scanner(System.in);
int v1 = input.nextInt();
int v2 = input.nextInt();
String line = input.nextLine();

◦ After the last statement is executed, line contains characters '7', '8', '9', '\n'.
◦ The program has a runtime error because 34.3 is not an integer.
◦ After the last statement is executed, v1 is 34.
◦ After the last statement is executed, line contains characters '7', '8', '9'.


Related Topics

Need homework help now?

Ask unlimited questions for free

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

AngeliqueG

  • Sr. Member
  • ****
  • Posts: 343
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 50% of students answer this correctly




pragya sharda

  • Member
  • Posts: 566
Reply 2 on: May 6, 2020
YES! Correct, THANKS for helping me on my review


miss.ashley

  • Member
  • Posts: 371
Reply 3 on: Yesterday
Great answer, keep it coming :)

 

Did you know?

Adolescents often feel clumsy during puberty because during this time of development, their hands and feet grow faster than their arms and legs do. The body is therefore out of proportion. One out of five adolescents actually experiences growing pains during this period.

Did you know?

Blood is approximately twice as thick as water because of the cells and other components found in it.

Did you know?

The most dangerous mercury compound, dimethyl mercury, is so toxic that even a few microliters spilled on the skin can cause death. Mercury has been shown to accumulate in higher amounts in the following types of fish than other types: swordfish, shark, mackerel, tilefish, crab, and tuna.

Did you know?

Atropine was named after the Greek goddess Atropos, the oldest and ugliest of the three sisters known as the Fates, who controlled the destiny of men.

Did you know?

Although not all of the following muscle groups are commonly used, intramuscular injections may be given into the abdominals, biceps, calves, deltoids, gluteals, laterals, pectorals, quadriceps, trapezoids, and triceps.

For a complete list of videos, visit our video library