Copro2 Midterm Exam

50 Questions | Attempts: 146
Share

SettingsSettingsSettings
Web Quizzes & Trivia

Choose the best answer.


Questions and Answers
  • 1. 

    1. What type of exception will you use if you are trying to access a non-existing file?

    • A.

      A. DiskFullException

    • B.

      B. FileNotFoundException

    • C.

      C. FileNotExistException

    • D.

      D. OutOfMemoryException

    Correct Answer
    B. B. FileNotFoundException
  • 2. 

    1. What type of exception will you use if you are trying to access an object which is null?

    • A.

      A. NullPointerException

    • B.

      B. StringIndexOutOfBoundsException

    • C.

      C. ArrayIndexOutOfBoundsException

    • D.

      D. IOException

    Correct Answer
    A. A. NullPointerException
  • 3. 

    1. Which of the following statement is required for handling user input error?

    • A.

      A. UserInputException

    • B.

      B. StringInputException

    • C.

      C. IOException

    • D.

      C. ArithmeticException

    Correct Answer
    C. C. IOException
  • 4. 

    These are normal errors that can occur during the execution of a program

    • A.

      A. error

    • B.

      B. exception

    • C.

      C. Runtime Exception

    • D.

      C. User Exception

    Correct Answer
    B. B. exception
  • 5. 

    This encompasses all exceptions which can ordinarily happen at runtime

    • A.

      A. error

    • B.

      B. exception

    • C.

      C. Runtime Exception

    • D.

      D. User Exception

    Correct Answer
    C. C. Runtime Exception
  • 6. 

    These are serious errors in the Java runtime system

    • A.

      A. error

    • B.

      B. exception

    • C.

      C. Runtime Exception

    • D.

      D. User Exception

    Correct Answer
    A. A. error
  • 7. 

    It takes a single argument which must be an object that is a subclass of Throwable.

    • A.

      A. error

    • B.

      B. exception

    • C.

      C. Runtime Exception

    • D.

      D. User Exception

    Correct Answer
    D. D. User Exception
  • 8. 

    It refers to letting the method’s caller catch the exception

    • A.

      A. passing on exceptions

    • B.

      B. catching exceptions

    • C.

      C. declaring exceptions

    • D.

      D. handling exceptions

    Correct Answer
    A. A. passing on exceptions
  • 9. 

    It refers to declaration that you can handle exceptions of a particular class from a particular block of code.

    • A.

      A. passing on exceptions

    • B.

      B. catching exceptions

    • C.

      C. declaring exceptions

    • D.

      D. handling exceptions

    Correct Answer
    B. B. catching exceptions
  • 10. 

    A block of code you attempt to execute while acknowledging that an exception might occur

    • A.

      A. finally block

    • B.

      B. try block

    • C.

      C. catch block

    • D.

      D. final block

    Correct Answer
    B. B. try block
  • 11. 

    A segment of code that can handle an exception that might be thrown by the try block that precedes it.

    • A.

      A. finally block

    • B.

      B. try block

    • C.

      C. catch block

    • D.

      D. final block

    Correct Answer
    C. C. catch block
  • 12. 

    A block of code when you have actions you must perform at the end of a try…catch blocks

    • A.

      A. finally block

    • B.

      B. try block

    • C.

      C. catch block

    • D.

      D. final block

    Correct Answer
    A. A. finally block
  • 13. 

    1. What type of exception will you use if you are trying to access a secure web browser?

    • A.

      A. SecurityException

    • B.

      B. FileNotFoundException

    • C.

      C. OnAccessException

    • D.

      D. IOException

    Correct Answer
    A. A. SecurityException
  • 14. 

    1. What type of exception will you use if you cannot read data from existing file?

    • A.

      A. ReaderException

    • B.

      B. FileNotFoundException

    • C.

      C. AccessException

    • D.

      D. IOException

    Correct Answer
    D. D. IOException
  • 15. 

    1. The File’s canWrite() method will return true if the file is __________.

    • A.

      A. rewritable

    • B.

      B. accessible

    • C.

      C. writable

    • D.

      D. readable

    Correct Answer
    C. C. writable
  • 16. 

    1. The File’s getName() method will return _________.

    • A.

      A. the name of the file

    • B.

      B. the name of the object

    • C.

      C. the name of the class

    • D.

      D. void

    Correct Answer
    A. A. the name of the file
  • 17. 

    Which of the following statements is true?

    • A.

      A. Errors are more serious than Exceptions

    • B.

      B. Exceptions are more serious than Errors

    • C.

      C. Errors and Exceptions are equally serious

    • D.

      D. Exceptions and errors are same thing

    Correct Answer
    A. A. Errors are more serious than Exceptions
  • 18. 

    The ______ package contains all the classes you use in file processing.

    • A.

      A. java.file

    • B.

      B. java.io

    • C.

      C. java.lang

    • D.

      D. java.process

    Correct Answer
    B. B. java.io
  • 19. 

    The file method canWrite returns a _________value.

    • A.

      A. integer

    • B.

      B. Boolean

    • C.

      C. Object

    • D.

      D. void

    Correct Answer
    B. B. Boolean
  • 20. 

    When you perform an input operation in a java program, you use a ___________.

    • A.

      A. pipeline

    • B.

      B. channel

    • C.

      C. moderator

    • D.

      D. stream

    Correct Answer
    D. D. stream
  • 21. 

    1. The File’s getParent() method will return _________.

    • A.

      A. the name of the folder which the file can be found

    • B.

      B. the name of the file which currently executing

    • C.

      C. the name of the folder in My Documents.

    • D.

      D. the default folder

    Correct Answer
    A. A. the name of the folder which the file can be found
  • 22. 

    This is a technique to manage errors comprises the group of methods

    • A.

      A. exception

    • B.

      B. error

    • C.

      C. error handling

    • D.

      D. exception handling

    Correct Answer
    D. D. exception handling
  • 23. 

    What type of exception will you use if your program attempt to divide a value to zero?

    • A.

      A. NullPointerExcption

    • B.

      B. ArithmeticException

    • C.

      C. ArrayIndexOutOfBounds

    • D.

      D. IOExcption

    Correct Answer
    B. B. ArithmeticException
  • 24. 

    What type of exception will you use if the user tries to enter a number instead of a character?

    • A.

      A. NullPointerExcption

    • B.

      B. ArithmeticException

    • C.

      C. ArrayIndexOutOfBounds

    • D.

      D. IOException

    Correct Answer
    D. D. IOException
  • 25. 

    What type of exception will you use if the user tries to save a file in a disk which is full?

    • A.

      A. DiskFullException

    • B.

      B. NullPointerException

    • C.

      C. OutOfStackException

    • D.

      D. OutOfMemoryException

    Correct Answer
    D. D. OutOfMemoryException
  • 26. 

    What type of exception will you use if you are trying to access a non-existing index?

    • A.

      A. NullPointerException

    • B.

      B. StringIndexOutOfBoundsException

    • C.

      C. ArrayIndexOutOfBoundsException

    • D.

      D. IOException

    Correct Answer
    C. C. ArrayIndexOutOfBoundsException
  • 27. 

    What type of exception will you use if you are trying to access a non-existing character?

    • A.

      A. NullPointerException

    • B.

      B. StringIndexOutOfBoundsException

    • C.

      C. ArrayIndexOutOfBoundsException

    • D.

      D. IOException

    Correct Answer
    B. B. StringIndexOutOfBoundsException
  • 28. 

    The following are the different constructors that can be used to create File object except?

    • A.

      A. File(String directoryPath)

    • B.

      B. File(String directoryPath, String filename)

    • C.

      C. File(File dirPath, String filename)

    • D.

      D. File(File dirObj, String filename)

    Correct Answer
    C. C. File(File dirPath, String filename)
  • 29. 

    The File’s exists() method will return true if the file is __________.

    • A.

      A. existing

    • B.

      B. accessible

    • C.

      C. writable

    • D.

      D. readable

    Correct Answer
    A. A. existing
  • 30. 

    The File’s canRead() method will return true if the file is __________.

    • A.

      A. existing

    • B.

      B. accessible

    • C.

      C. writable

    • D.

      D. readable

    Correct Answer
    D. D. readable
  • 31. 

    The java.io package contains a ___________ class that is used to read from and write data to anywhere in a file.

    • A.

      A. RandAccessFile

    • B.

      B. RandomAccessFile

    • C.

      C. AccessFile

    • D.

      D. ReadWriteFile

    Correct Answer
    B. B. RandomAccessFile
  • 32. 

    The method __________ moves the file pointer in the forward direction by the number of bytes that are specified

    • A.

      A. getFilePonter()

    • B.

      B. seek()

    • C.

      C. skipBytes()

    • D.

      D. search()

    Correct Answer
    C. C. skipBytes()
  • 33. 

     The method _________ is used for moving the file pointer to specific positions

    • A.

      A. getFilePonter()

    • B.

      B. seek()

    • C.

      C. skipBytes()

    • D.

      D. search()

    Correct Answer
    B. B. seek()
  • 34. 

    The method ___________ is used for obtaining the current location of the file pointer

    • A.

      A. getFilePonter()

    • B.

      B. seek()

    • C.

      C. skipBytes()

    • D.

      D. search()

    Correct Answer
    A. A. getFilePonter()
  • 35. 

     It is a sequence of data flowing from a source to a destination.

    • A.

      A. data flow

    • B.

      B. stream

    • C.

      C. input

    • D.

      D. output

    Correct Answer
    B. B. stream
  • 36. 

    The character streams are used to transfer _______ of characters.

    • A.

      A. 8 bits

    • B.

      B. 8 bytes

    • C.

      C. 16 bits

    • D.

      D. 32 bytes

    Correct Answer
    C. C. 16 bits
  • 37. 

    It is a storage place where data can be kept before it is needed by a program that reads or writes that data.

    • A.

      A. reader

    • B.

      B. writer

    • C.

      C. buffer

    • D.

      D. stream

    Correct Answer
    C. C. buffer
  • 38. 

    1. The File’s length() method will return _________.

    • A.

      A. the file’s size

    • B.

      B. the file’s length

    • C.

      C. the file’s capacity

    • D.

      D. void

    Correct Answer
    A. A. the file’s size
  • 39. 

    1. The File’s lastModified() method will return _________.

    • A.

      A. the file it was first opened

    • B.

      B. the file it was last modified

    • C.

      Cc. the file it was recently opened

    • D.

      D. the file it was last accessed

    Correct Answer
    B. B. the file it was last modified
  • 40. 

    1. The RandomAccessFile supports the concept of a _________ that is used to indicate the current location of the file.

    • A.

      A. file cursor

    • B.

      B. file pointer

    • C.

      C. file manager

    • D.

      D. file location

    Correct Answer
    B. B. file pointer
  • 41. 

    1. It comprises of data flowing into a program

    • A.

      A. buffered reader

    • B.

      B. buffered writer

    • C.

      C. input stream

    • D.

      D. output stream

    Correct Answer
    C. C. input stream
  • 42. 

    FileNotFoundException is caused by general I/O failures, such as inability to read from a file

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
  • 43. 

    The try-catch block can be nested

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
  • 44. 

    The exception must be of the Throwable class or one of its subclasses

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
  • 45. 

    You can use Byte Streams in reading and writing character data

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
  • 46. 

    A throws clause lists the types of exceptions that a method might throw

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
  • 47. 

    Each catch block defines an exception handle

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
  • 48. 

    The two modes of a file are readable and writable

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
  • 49. 

    Characters in Java are Unicode characters composed of two bits

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
  • 50. 

    For each try block, there can be one or more catch blocks, but at most only one finally block

    • A.

      True

    • B.

      False

    Correct Answer
    A. True

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Jan 22, 2013
    Quiz Edited by
    ProProfs Editorial Team
  • Feb 07, 2011
    Quiz Created by
    Jhaicee
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.