No Markers

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page        

Answer:

No.

No Markers

The bytes on the disk are just raw bytes. You (the programmer) have to know what you wrote in order to make sense of it. Here is another program:

import java.io.*;
class TwoShorts
{
  public static void main ( String[] args ) throws IOException
  {
    String fileName = "mixedTypes.dat" ;

    DataOutputStream dataOut = new DataOutputStream(
        new BufferedOutputStream(
        new FileOutputStream( fileName  ) ) );

    dataOut.writeShort( 0 );
    dataOut.writeShort( 0 );

    dataOut.writeDouble( 12.45 );

    dataOut.close();
  }
}

Two 16-bit shorts are written, each containing a zero. The previous program wrote a 32-bit zero. The double is the same as before.

QUESTION 15:

What will the output file look like?