Kamis, 13 April 2017

SECTION 3 ALTERNATIF 1

Section 3 - Quiz 2 L4-L6
  (Answer all questions in this section)
 
  1.   In what order do multiple catch statements execute?  Mark for Review
(1) Points
 
 
The order they are declared in ( most specific first). (*)

 
They all execute at the same time.

 
The order they are declared in (most general first).

 
None of them execute since you cannot have multiple catch statements.

 
  Correct

 
  2.   When do errors occur in code?  Mark for Review
(1) Points
 
  (Choose all correct answers)
 
 
When files are not found or are unreadable. (*)

 
When hardware issues occur (e.g., not enough memory). (*)

 
When an exception is thrown (*)

 
When there is an error in your logic. (*)

 
  Incorrect. Refer to Section 3 Lesson 6.

 
  3.   When is the proper time to use exceptions?  Mark for Review
(1) Points
 
 
When you want to print statements to the screen.

 
When you want to efficiently and reliably debug your program. (*)

 
If you purposefully put errors in your code you wish to handle.

 
Every time a new method is called.

 
  Correct

 
  4.   Assertions are boolean statements to test and debug your programs.
True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Incorrect. Refer to Section 3 Lesson 6.

 
  5.   Assertions are optional ways to catch logic errors in code.
True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Correct

6.   Methods can not throw exceptions.
True or false?  Mark for Review
(1) Points
 
 
True

 
False (*)

 
  Correct

 
  7.   Is this the correct syntax for catching an exception?
try(inputStream = "missingfile.txt"); catch(exception e);
True or false?  Mark for Review
(1) Points
 
 
True

 
False (*)

 
  Correct

 
  8.   The BufferedOutputStream is a direct subclass of what other class?  Mark for Review
(1) Points
 
 
OutputStream

 
ObjectOutputStream

 
FilterOutputStream (*)

 
PrintStream

 
DigestOutputStream

 
  Incorrect. Refer to Section 3 Lesson 5.

 
  9.   The read() method lets you read a character at a time. True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Incorrect. Refer to Section 3 Lesson 5.

 
  10.   A serialized class implements which interface?  Mark for Review
(1) Points
 
 
Serializer

 
Serializing

 
Serializable (*)

 
SerializedObject

 
Serialized

 
  Incorrect. Refer to Section 3 Lesson 5.

11.   The Files class lets you check for file properties. True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Incorrect. Refer to Section 3 Lesson 5.

 
  12.   Which of the following is an absolute Windows path?  Mark for Review
(1) Points
 
 
/home/user/username

 
data

 
\Users\UserName\data

 
/

 
C:\Users\UserName\data (*)

 
  Incorrect. Refer to Section 3 Lesson 4.

 
  13.   The java.nio.file package has improved exception handling.
True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Incorrect. Refer to Section 3 Lesson 4.

 
  14.   Java 7 requires you create an instance of java.io.File class. True or false?  Mark for Review
(1) Points
 
 
True

 
False (*)

 
  Correct

 
  15.   The java.io package has problems with missing operations, like copy, move, and such.
True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Correct

1.   The normalize() method removes extraneous elements from a qualified path. True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Incorrect. Refer to Section 3 Lesson 4.

 
  2.   Prior to Java 7, you write to a file with a call to the BufferedWriter class's write() method. True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Incorrect. Refer to Section 3 Lesson 4.

 
  3.   The Files class performs which of the following?  Mark for Review
(1) Points
 
 
Works with absolute paths

 
Navigates the file system

 
Creates files (*)

 
Works with relative paths

 
Works across disk volumes

 
  Incorrect. Refer to Section 3 Lesson 4.

 
  4.   The new Paths class lets you resolve .. (double dot) path notation. True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Incorrect. Refer to Section 3 Lesson 4.

 
  5.   What is one step you must do to create your own exception?  Mark for Review
(1) Points
 
 
Declare the primitive data type Exception.

 
Create a new class that implements Exception.

 
Create a new class that extends Exception. (*)

 
Exceptions cannot be created. They are only built in to Java.

 
  Correct

6.   Assertions are boolean statements to test and debug your programs.
True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Incorrect. Refer to Section 3 Lesson 6.

 
  7.   Is this the correct syntax for catching an exception?
try(inputStream = "missingfile.txt"); catch(exception e);
True or false?  Mark for Review
(1) Points
 
 
True

 
False (*)

 
  Correct

 
  8.   Assertions are optional ways to catch logic errors in code.
True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Correct

 
  9.   What is special about including a resource in a try statement?  Mark for Review
(1) Points
 
  (Choose all correct answers)
 
 
The resources will auto-close. (*)

 
The program will fail if the resource does not open.

 
An error will be thrown if the resources does not open. (*)

 
  Incorrect. Refer to Section 3 Lesson 6.

 
  10.   When do you use try-catch statements?  Mark for Review
(1) Points
 
 
Every time you would like to assign a new value to a variable that is being asserted.

 
If you want to switch different values for a certain variable.

 
When you want to exit your code before an exception is caught.

 
When you want to handle an exception. (*)

 
  Incorrect. Refer to Section 3 Lesson 6.

11.   When should you not use assertions?  Mark for Review
(1) Points
 
  (Choose all correct answers)
 
 
When you want your program to execute efficiently.

 
When you believe you have no bugs in your code.

 
When you want to check the values of parameters. (*)

 
When you call methods that may cause side effects in your assertion check. (*)

 
  Incorrect. Refer to Section 3 Lesson 6.

 
  12.   File permissions are the same across all of the different operating systems.  Mark for Review
(1) Points
 
 
True

 
False (*)

 
  Incorrect. Refer to Section 3 Lesson 5.

 
  13.   When you delete files, directories, or links with the delete(Path p) method which of the following exceptions can occur (Choose all that apply).  Mark for Review
(1) Points
 
  (Choose all correct answers)
 
 
NoSuchFileException (*)

 
DirectoryNotEmptyException (*)

 
No exception is thrown

 
IOException (*)

 
  Incorrect. Refer to Section 3 Lesson 5.

 
  14.   The System.out is what type of stream?  Mark for Review
(1) Points
 
 
A PrintStream (*)

 
A BufferedWriter stream

 
An OutputStream

 
A Reader stream

 
A BufferedReader stream

 
  Incorrect. Refer to Section 3 Lesson 5.

 
  15.   The read() method lets you read a character at a time. True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Correct

1.   The finally clause only executes when an exception is not caught and thrown.
True or false?  Mark for Review
(1) Points
 
 
True

 
False (*)

 
  Correct

 
  2.   What is one step you must do to create your own exception?  Mark for Review
(1) Points
 
 
Create a new class that extends Exception. (*)

 
Create a new class that implements Exception.

 
Exceptions cannot be created. They are only built in to Java.

 
Declare the primitive data type Exception.

 
  Incorrect. Refer to Section 3 Lesson 6.

 
  3.   When do errors occur in code?  Mark for Review
(1) Points
 
  (Choose all correct answers)
 
 
When there is an error in your logic. (*)

 
When an exception is thrown (*)

 
When hardware issues occur (e.g., not enough memory). (*)

 
When files are not found or are unreadable. (*)

 
  Incorrect. Refer to Section 3 Lesson 6.

 
  4.   Assertions are optional ways to catch logic errors in code.
True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Incorrect. Refer to Section 3 Lesson 6.

 
  5.   When do you use try-catch statements?  Mark for Review
(1) Points
 
 
When you want to exit your code before an exception is caught.

 
When you want to handle an exception. (*)

 
Every time you would like to assign a new value to a variable that is being asserted.

 
If you want to switch different values for a certain variable.

 
  Incorrect. Refer to Section 3 Lesson 6.

6.   Why should you not use assertions to check parameters?  Mark for Review
(1) Points
 
 
Not all methods have parameters, therefore assertions should never be used on parameters.

 
Assertions can be disabled at run time which may cause unexpected results in your assertions. (*)

 
Assertions do not work on parameters.

 
It is hard to assume expected values for parameters.

 
  Incorrect. Refer to Section 3 Lesson 6.

 
  7.   Multiple catch statements can be used for a single try statement.
True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Incorrect. Refer to Section 3 Lesson 6.

 
  8.   An ObjectInputStream lets you read a serialized object. True or false?  Mark for Review
(1) Points
 
 
True

 
False (*)

 
  Correct

 
  9.   File permissions are the same across all of the different operating systems.  Mark for Review
(1) Points
 
 
True

 
False (*)

 
  Incorrect. Refer to Section 3 Lesson 5.

 
  10.   The Files class lets you check for file properties. True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Incorrect. Refer to Section 3 Lesson 5.

11.   The System.in is what type of stream?  Mark for Review
(1) Points
 
 
A Reader stream

 
An InputStream (*)

 
A PrintStream

 
A BufferedWriter stream

 
A BufferedReader stream

 
  Incorrect. Refer to Section 3 Lesson 5.

 
  12.   The normalize() method removes extraneous elements from a qualified path. True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Incorrect. Refer to Section 3 Lesson 4.

 
  13.   The new Paths class lets you resolve .. (double dot) path notation. True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Incorrect. Refer to Section 3 Lesson 4.

 
  14.   The java.nio.file package has improved exception handling.
True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Incorrect. Refer to Section 3 Lesson 4.

 
  15.   An absolute path always starts from the drive letter or mount point.  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Incorrect. Refer to Section 3 Lesson 4.

What two packages are available in Java to allow you to transfer data?  Mark for Review
(1) Points
 
  (Choose all correct answers)
 
 
java.nio.file package (*)

 
java.output.package

 
java.io package (*)

 
java.input.package

 
  Incorrect. Refer to Section 3 Lesson 4.


 
  7.   What is the definition of a logic error?  Mark for Review
(1) Points
 
 
Bugs in code that make your program run different than expected (*)

 
Something that causes your computer to crash.

 
Wrong syntax that will be caught at compile time.

 
Computer malfunction that makes your code run incorrectly.

 
  Incorrect. Refer to Section 3 Lesson 6.

12.   The BufferedInputStream is a direct subclass of what other class?  Mark for Review
(1) Points
 
 
FileInputStream

 
FilterInputStream (*)

 
InputStream

 
InputStream

 
PipedInputStream

 
  Incorrect. Refer to Section 3 Lesson 5.

1.   Java 7 requires you create an instance of java.io.File class. True or false?  Mark for Review
(1) Points
 
 
True

 
False (*)

 
  Correct

 
  2.   Which of the following is an absolute Windows path?  Mark for Review
(1) Points
 
 
/home/user/username

 
/

 
\Users\UserName\data

 
data

 
C:\Users\UserName\data (*)

 
  Correct

 
  3.   The java.nio.file package has improved exception handling.
True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Correct

 
  4.   The way that you read from a file has changed since the introduction of Java 7.  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Correct

 
  5.   What is the definition of a logic error?  Mark for Review
(1) Points
 
 
Computer malfunction that makes your code run incorrectly.

 
Wrong syntax that will be caught at compile time.

 
Something that causes your computer to crash.

 
Bugs in code that make your program run different than expected (*)

 
  Correct

6.   Is this the correct syntax for catching an exception?
try(inputStream = "missingfile.txt"); catch(exception e);
True or false?  Mark for Review
(1) Points
 
 
True

 
False (*)

 
  Correct

 
  7.   Why should you not use assertions to check parameters?  Mark for Review
(1) Points
 
 
Assertions can be disabled at run time which may cause unexpected results in your assertions. (*)

 
Not all methods have parameters, therefore assertions should never be used on parameters.

 
It is hard to assume expected values for parameters.

 
Assertions do not work on parameters.

 
  Correct

 
  8.   Multiple exceptions can be caught in one catch statement.
True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Correct

 
  9.   When do errors occur in code?  Mark for Review
(1) Points
 
  (Choose all correct answers)
 
 
When files are not found or are unreadable. (*)

 
When an exception is thrown (*)

 
When there is an error in your logic. (*)

 
When hardware issues occur (e.g., not enough memory). (*)

 
  Correct

 
  10.   When do you use try-catch statements?  Mark for Review
(1) Points
 
 
When you want to exit your code before an exception is caught.

 
When you want to handle an exception. (*)

 
Every time you would like to assign a new value to a variable that is being asserted.

 
If you want to switch different values for a certain variable.

 
  Correct

11.   Multiple catch statements can be used for a single try statement.
True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Correct

 
  12.   When you delete files, directories, or links with the delete(Path p) method which of the following exceptions can occur (Choose all that apply).  Mark for Review
(1) Points
 
  (Choose all correct answers)
 
 
NoSuchFileException (*)

 
No exception is thrown

 
DirectoryNotEmptyException (*)

 
IOException (*)

 
  Incorrect. Refer to Section 3 Lesson 5.

 
  13.   Which of the following static methods is not provided by the Files class to check file properties or duplication?  Mark for Review
(1) Points
 
 
Files.isWritable(Path p);

 
Files.isArchived(Path p); (*)

 
Files.isReadable(Path p);

 
Files.isHidden(Path p);

 
  Correct

 
  14.   A serialized class implements which interface?  Mark for Review
(1) Points
 
 
Serializer

 
Serialized

 
Serializing

 
Serializable (*)

 
SerializedObject

 
  Correct

 
  15.   The System.out is what type of stream?  Mark for Review
(1) Points
 
 
An OutputStream

 
A BufferedReader stream

 
A BufferedWriter stream

 
A PrintStream (*)

 
A Reader stream

 
  Correct


0 komentar:

Posting Komentar

luvne.com ayeey.com cicicookies.com mbepp.com kumpulanrumusnya.com.com tipscantiknya.com