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 221 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
Gracias!


Sarahjh

  • Member
  • Posts: 370
Reply 3 on: Yesterday
Thanks for the timely response, appreciate it

 

Did you know?

Women are 50% to 75% more likely than men to experience an adverse drug reaction.

Did you know?

Individuals are never “cured” of addictions. Instead, they learn how to manage their disease to lead healthy, balanced lives.

Did you know?

This year, an estimated 1.4 million Americans will have a new or recurrent heart attack.

Did you know?

More than 30% of American adults, and about 12% of children utilize health care approaches that were developed outside of conventional medicine.

Did you know?

Ether was used widely for surgeries but became less popular because of its flammability and its tendency to cause vomiting. In England, it was quickly replaced by chloroform, but this agent caused many deaths and lost popularity.

For a complete list of videos, visit our video library