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 18 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
Great answer, keep it coming :)


sultana.d

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

 

Did you know?

The longest a person has survived after a heart transplant is 24 years.

Did you know?

HIV testing reach is still limited. An estimated 40% of people with HIV (more than 14 million) remain undiagnosed and do not know their infection status.

Did you know?

According to animal studies, the typical American diet is damaging to the liver and may result in allergies, low energy, digestive problems, and a lack of ability to detoxify harmful substances.

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?

Medication errors are more common among seriously ill patients than with those with minor conditions.

For a complete list of videos, visit our video library