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 213 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


fatboyy09

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

 

Did you know?

The top five reasons that children stay home from school are as follows: colds, stomach flu (gastroenteritis), ear infection (otitis media), pink eye (conjunctivitis), and sore throat.

Did you know?

The average adult has about 21 square feet of skin.

Did you know?

In the ancient and medieval periods, dysentery killed about ? of all babies before they reach 12 months of age. The disease was transferred through contaminated drinking water, because there was no way to adequately dispose of sewage, which contaminated the water.

Did you know?

The average office desk has 400 times more bacteria on it than a toilet.

Did you know?

Vital signs (blood pressure, temperature, pulse rate, respiration rate) should be taken before any drug administration. Patients should be informed not to use tobacco or caffeine at least 30 minutes before their appointment.

For a complete list of videos, visit our video library