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


dawsa925

  • Member
  • Posts: 326
Reply 3 on: Yesterday
:D TYSM

 

Did you know?

Illness; diuretics; laxative abuse; hot weather; exercise; sweating; caffeine; alcoholic beverages; starvation diets; inadequate carbohydrate consumption; and diets high in protein, salt, or fiber can cause people to become dehydrated.

Did you know?

There are major differences in the metabolism of morphine and the illegal drug heroin. Morphine mostly produces its CNS effects through m-receptors, and at k- and d-receptors. Heroin has a slight affinity for opiate receptors. Most of its actions are due to metabolism to active metabolites (6-acetylmorphine, morphine, and morphine-6-glucuronide).

Did you know?

During the twentieth century, a variant of the metric system was used in Russia and France in which the base unit of mass was the tonne. Instead of kilograms, this system used millitonnes (mt).

Did you know?

More than 30% of American adults, and about 12% of children utilize health care approaches that were developed outside of conventional medicine.

Did you know?

Walt Disney helped combat malaria by making an animated film in 1943 called The Winged Scourge. This short film starred the seven dwarfs and taught children that mosquitos transmit malaria, which is a very bad disease. It advocated the killing of mosquitos to stop the disease.

For a complete list of videos, visit our video library