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 17 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 :)


connor417

  • Member
  • Posts: 329
Reply 3 on: Yesterday
Wow, this really help

 

Did you know?

The most common childhood diseases include croup, chickenpox, ear infections, flu, pneumonia, ringworm, respiratory syncytial virus, scabies, head lice, and asthma.

Did you know?

Most strokes are caused when blood clots move to a blood vessel in the brain and block blood flow to that area. Thrombolytic therapy can be used to dissolve the clot quickly. If given within 3 hours of the first stroke symptoms, this therapy can help limit stroke damage and disability.

Did you know?

Each year in the United States, there are approximately six million pregnancies. This means that at any one time, about 4% of women in the United States are pregnant.

Did you know?

Human stomach acid is strong enough to dissolve small pieces of metal such as razor blades or staples.

Did you know?

Adults are resistant to the bacterium that causes Botulism. These bacteria thrive in honey – therefore, honey should never be given to infants since their immune systems are not yet resistant.

For a complete list of videos, visit our video library