The IT Certification Resource Center

Featured Deal

Get CompTIA, Cisco, and Microsoft training courses free for a week.
Learn More ❯

Question 19:

How can you replace the comment at the end of main() with code that will write the integers 0 through 9?

import java.io.*; 
  
class Write 
{ 
    public static void main(String[] args) throws Exception 
    { 
        File file = new File("temp.test"); 
        FileOutputStream stream = new FileOutputStream(file); 
        // write integers here. . . 
    }
}
A.
DataOutputStream filter = new DataOutputStream(stream); 
for (int i = 0; i < 10; i++) 
{
    filter.writeInt(i); 
}
					
 
B.
for (int i = 0; i < 10; i++) 
{
    file.writeInt(i); 
}
					
 
C.
for (int i = 0; i < 10; i++) 
{
     stream.writeInt(i);
}
					
 
D.
DataOutputStream filter = new DataOutputStream(stream); 
for (int i = 0; i < 10; i++) 
{
    filter.write(i);
}
					
 
E.
for (int i = 0; i < 10; i++) 
{
    stream.write(i);
}