Copro2 Midterm Exam

50 Questions | Attempts: 146
Share
SettingsSettings
Please wait...
  • 1/50 Questions

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

    • True
    • False
Please wait...
About This Quiz

Choose the best answer.

Web Quizzes & Trivia

Quiz Preview

  • 2. 

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

    • A. the name of the file

    • B. the name of the object

    • C. the name of the class

    • D. void

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

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

    • A. existing

    • B. accessible

    • C. writable

    • D. readable

    Correct Answer
    A. D. readable
  • 4. 

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

    • A. the file it was first opened

    • B. the file it was last modified

    • Cc. the file it was recently opened

    • D. the file it was last accessed

    Correct Answer
    A. B. the file it was last modified
  • 5. 

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

    • True

    • False

    Correct Answer
    A. True
  • 6. 

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

    • A. NullPointerException

    • B. StringIndexOutOfBoundsException

    • C. ArrayIndexOutOfBoundsException

    • D. IOException

    Correct Answer
    A. A. NullPointerException
  • 7. 

    Each catch block defines an exception handle

    • True

    • False

    Correct Answer
    A. True
  • 8. 

    This encompasses all exceptions which can ordinarily happen at runtime

    • A. error

    • B. exception

    • C. Runtime Exception

    • D. User Exception

    Correct Answer
    A. C. Runtime Exception
  • 9. 

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

    • A. SecurityException

    • B. FileNotFoundException

    • C. OnAccessException

    • D. IOException

    Correct Answer
    A. A. SecurityException
  • 10. 

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

    • A. NullPointerExcption

    • B. ArithmeticException

    • C. ArrayIndexOutOfBounds

    • D. IOExcption

    Correct Answer
    A. B. ArithmeticException
  • 11. 

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

    • A. existing

    • B. accessible

    • C. writable

    • D. readable

    Correct Answer
    A. A. existing
  • 12. 

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

    • A. data flow

    • B. stream

    • C. input

    • D. output

    Correct Answer
    A. B. stream
  • 13. 

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

    • True

    • False

    Correct Answer
    A. True
  • 14. 

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

    • A. RandAccessFile

    • B. RandomAccessFile

    • C. AccessFile

    • D. ReadWriteFile

    Correct Answer
    A. B. RandomAccessFile
  • 15. 

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

    • A. error

    • B. exception

    • C. Runtime Exception

    • D. User Exception

    Correct Answer
    A. D. User Exception
  • 16. 

    The file method canWrite returns a _________value.

    • A. integer

    • B. Boolean

    • C. Object

    • D. void

    Correct Answer
    A. B. Boolean
  • 17. 

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

    • A. pipeline

    • B. channel

    • C. moderator

    • D. stream

    Correct Answer
    A. D. stream
  • 18. 

    You can use Byte Streams in reading and writing character data

    • True

    • False

    Correct Answer
    A. True
  • 19. 

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

    • A. finally block

    • B. try block

    • C. catch block

    • D. final block

    Correct Answer
    A. C. catch block
  • 20. 

    Which of the following statements is true?

    • A. Errors are more serious than Exceptions

    • B. Exceptions are more serious than Errors

    • C. Errors and Exceptions are equally serious

    • D. Exceptions and errors are same thing

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

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

    • A. java.file

    • B. java.io

    • C. java.lang

    • D. java.process

    Correct Answer
    A. B. java.io
  • 22. 

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

    • A. DiskFullException

    • B. NullPointerException

    • C. OutOfStackException

    • D. OutOfMemoryException

    Correct Answer
    A. D. OutOfMemoryException
  • 23. 

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

    • A. reader

    • B. writer

    • C. buffer

    • D. stream

    Correct Answer
    A. C. buffer
  • 24. 

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

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

    • B. the name of the file which currently executing

    • C. the name of the folder in My Documents.

    • D. the default folder

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

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

    • A. error

    • B. exception

    • C. Runtime Exception

    • C. User Exception

    Correct Answer
    A. B. exception
  • 26. 

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

    • A. finally block

    • B. try block

    • C. catch block

    • D. final block

    Correct Answer
    A. B. try block
  • 27. 

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

    • A. rewritable

    • B. accessible

    • C. writable

    • D. readable

    Correct Answer
    A. C. writable
  • 28. 

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

    • A. getFilePonter()

    • B. seek()

    • C. skipBytes()

    • D. search()

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

    The character streams are used to transfer _______ of characters.

    • A. 8 bits

    • B. 8 bytes

    • C. 16 bits

    • D. 32 bytes

    Correct Answer
    A. C. 16 bits
  • 30. 

    These are serious errors in the Java runtime system

    • A. error

    • B. exception

    • C. Runtime Exception

    • D. User Exception

    Correct Answer
    A. A. error
  • 31. 

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

    • A. exception

    • B. error

    • C. error handling

    • D. exception handling

    Correct Answer
    A. D. exception handling
  • 32. 

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

    • A. NullPointerException

    • B. StringIndexOutOfBoundsException

    • C. ArrayIndexOutOfBoundsException

    • D. IOException

    Correct Answer
    A. C. ArrayIndexOutOfBoundsException
  • 33. 

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

    • A. NullPointerException

    • B. StringIndexOutOfBoundsException

    • C. ArrayIndexOutOfBoundsException

    • D. IOException

    Correct Answer
    A. B. StringIndexOutOfBoundsException
  • 34. 

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

    • A. getFilePonter()

    • B. seek()

    • C. skipBytes()

    • D. search()

    Correct Answer
    A. C. skipBytes()
  • 35. 

    1. It comprises of data flowing into a program

    • A. buffered reader

    • B. buffered writer

    • C. input stream

    • D. output stream

    Correct Answer
    A. C. input stream
  • 36. 

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

    • A. passing on exceptions

    • B. catching exceptions

    • C. declaring exceptions

    • D. handling exceptions

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

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

    • A. finally block

    • B. try block

    • C. catch block

    • D. final block

    Correct Answer
    A. A. finally block
  • 38. 

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

    • A. passing on exceptions

    • B. catching exceptions

    • C. declaring exceptions

    • D. handling exceptions

    Correct Answer
    A. B. catching exceptions
  • 39. 

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

    • A. the file’s size

    • B. the file’s length

    • C. the file’s capacity

    • D. void

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

    The two modes of a file are readable and writable

    • True

    • False

    Correct Answer
    A. False
  • 41. 

    Characters in Java are Unicode characters composed of two bits

    • True

    • False

    Correct Answer
    A. False
  • 42. 

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

    • A. DiskFullException

    • B. FileNotFoundException

    • C. FileNotExistException

    • D. OutOfMemoryException

    Correct Answer
    A. B. FileNotFoundException
  • 43. 

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

    • A. UserInputException

    • B. StringInputException

    • C. IOException

    • C. ArithmeticException

    Correct Answer
    A. C. IOException
  • 44. 

    The try-catch block can be nested

    • True

    • False

    Correct Answer
    A. False
  • 45. 

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

    • A. File(String directoryPath)

    • B. File(String directoryPath, String filename)

    • C. File(File dirPath, String filename)

    • D. File(File dirObj, String filename)

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

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

    • A. ReaderException

    • B. FileNotFoundException

    • C. AccessException

    • D. IOException

    Correct Answer
    A. D. IOException
  • 47. 

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

    • A. file cursor

    • B. file pointer

    • C. file manager

    • D. file location

    Correct Answer
    A. B. file pointer
  • 48. 

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

    • True

    • False

    Correct Answer
    A. False
  • 49. 

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

    • A. NullPointerExcption

    • B. ArithmeticException

    • C. ArrayIndexOutOfBounds

    • D. IOException

    Correct Answer
    A. D. IOException

Quiz Review Timeline (Updated): Jan 22, 2013 +

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.