COMP 274 Week 6 Java Theory Question

profileaakashagarwal
 (Not rated)
 (Not rated)
Chat

COMP 274

Week 6 Homework

 

 

Homework Questions

 

  1. What is the difference between throwing an exception and catching an exception?
  2. How does a method declare that it can throw an exception? How does it actually throw an exception? Use Java code to illustrate your answer.

 

  1. Explain the difference between a checked exception and an unchecked exception.

 

  1. What happens if an exception does not have a matching catch block?

 

  1. What can a catch block do with the exception object that it receives?

 

  1. What is the purpose of the finally block?

 

  1. What is the difference between text I/O and binary I/O?

 

  1. What happens if you try to create a FileInputStream on a file that does not exist?

 

  1. What happens if you try to create a FileOutputStream on a file that does not exist?
  2. What are BufferedInput/OutputStreams and why are they used? Write some Java code to illustrate how to create a BufferedInputStream.

 

  1. Write the line of code you would need to open the file c:\temp\mydata.txt for reading primitive data values from the file such as doubles, floats, ints, etc.

 

  1. Write lines of code to create object input and output streams for the file c:\temp\mydata.out.

 

  1. What is the difference between sequential access and random access?

 

 

 

 

    • 12 years ago
    Perfect Answers
    NOT RATED

    Purchase the answer to view it

    blurred-text
    • attachment
      exception.docx