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 211 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
:D TYSM


nathang24

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

 

Did you know?

The Centers for Disease Control and Prevention has released reports detailing the deaths of infants (younger than 1 year of age) who died after being given cold and cough medications. This underscores the importance of educating parents that children younger than 2 years of age should never be given over-the-counter cold and cough medications without consulting their physicians.

Did you know?

Though “Krazy Glue” or “Super Glue” has the ability to seal small wounds, it is not recommended for this purpose since it contains many substances that should not enter the body through the skin, and may be harmful.

Did you know?

The Centers for Disease Control and Prevention (CDC) was originally known as the Communicable Disease Center, which was formed to fight malaria. It was originally headquartered in Atlanta, Georgia, since the Southern states faced the worst threat from malaria.

Did you know?

A recent study has found that following a diet rich in berries may slow down the aging process of the brain. This diet apparently helps to keep dopamine levels much higher than are seen in normal individuals who do not eat berries as a regular part of their diet as they enter their later years.

Did you know?

Acetaminophen (Tylenol) in overdose can seriously damage the liver. It should never be taken by people who use alcohol heavily; it can result in severe liver damage and even a condition requiring a liver transplant.

For a complete list of videos, visit our video library