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


blakcmamba

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

 

Did you know?

Excessive alcohol use costs the country approximately $235 billion every year.

Did you know?

Amoebae are the simplest type of protozoans, and are characterized by a feeding and dividing trophozoite stage that moves by temporary extensions called pseudopodia or false feet.

Did you know?

People about to have surgery must tell their health care providers about all supplements they take.

Did you know?

In 1844, Charles Goodyear obtained the first patent for a rubber condom.

Did you know?

Anti-aging claims should not ever be believed. There is no supplement, medication, or any other substance that has been proven to slow or stop the aging process.

For a complete list of videos, visit our video library