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

Author Question: What happens if the file test.dat does not exist when you attempt to compile and run the following ... (Read 16 times)

Mollykgkg

  • Hero Member
  • *****
  • Posts: 529
What happens if the file test.dat does not exist when you attempt to compile and run the following code?

import java.io.*;

class Test {
public static void main(String[] args) {
try {
RandomAccessFile raf =
new RandomAccessFile("test.dat", "r");
int i = raf.readInt();
}
catch(IOException ex) {
System.out.println("IO exception");
}
}
}

◦ The program compiles and runs fine, but nothing is displayed on the console.
◦ The program compiles, but throws IOException because the file test.dat doesn't exist. The program displays IO exception.
◦ The program does not compile because raf is not created correctly.
◦ The program does not compile because readInt() is not implemented in RandomAccessFile.


Related Topics

Need homework help now?

Ask unlimited questions for free

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

Madisongo23

  • Sr. Member
  • ****
  • Posts: 325
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




Mollykgkg

  • Member
  • Posts: 529
Reply 2 on: May 6, 2020
Thanks for the timely response, appreciate it


EAN94

  • Member
  • Posts: 307
Reply 3 on: Yesterday
YES! Correct, THANKS for helping me on my review

 

Did you know?

Chronic necrotizing aspergillosis has a slowly progressive process that, unlike invasive aspergillosis, does not spread to other organ systems or the blood vessels. It most often affects middle-aged and elderly individuals, spreading to surrounding tissue in the lungs. The disease often does not respond to conventionally successful treatments, and requires individualized therapies in order to keep it from becoming life-threatening.

Did you know?

Immunoglobulin injections may give short-term protection against, or reduce severity of certain diseases. They help people who have an inherited problem making their own antibodies, or those who are having certain types of cancer treatments.

Did you know?

Cytomegalovirus affects nearly the same amount of newborns every year as Down syndrome.

Did you know?

The tallest man ever known was Robert Wadlow, an American, who reached the height of 8 feet 11 inches. He died at age 26 years from an infection caused by the immense weight of his body (491 pounds) and the stress on his leg bones and muscles.

Did you know?

The first war in which wide-scale use of anesthetics occurred was the Civil War, and 80% of all wounds were in the extremities.

For a complete list of videos, visit our video library