1. Trang chủ
  2. » Công Nghệ Thông Tin

05 BTNB quiz3 exception handling utilities

44 2,6K 9

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 44
Dung lượng 285,76 KB

Nội dung

Question 19 of 200.0 5.0 PointsSelect a collection type that match all condition bellow : it is implemented as a circular buffer. It follows LIFO (last in first out ) system. it is a weakly typed collection. Push method allows you to add items to it Peek method just gets the last object of it Pop method also get the last object and then removes that item from it A. Stack Class B. Queue Class C. HashTable Class D. Array class Question 20 of 200.0 5.0 PointsSelect a collection type that match all condition bellow : It is useful for storing messages in the order they were received for sequential processing. it maintains FIFO (first in first out) system. With it you can create weakly typed collections that are ordered by the order they are added to the collection. It accepts a null reference as a valid value and allows duplicate elements. Objects stored in it are inserted at one end and removed from the other. A. Queue Class B. Array class C. Stack Class D. HashTable Class

Trang 1

Part 1 of 2 - Part 1 65.0/ 75.0 Points

Trang 2

A Finally block is used to enclose code that needs to run, regardless of whether an exception is raised

B Finally block is executed only when no error occurs

C Finally block will be executed only if an error occurs

D Finally block is executed after Catch block when no error occurs

Trang 3

What will be the output of above code when compiled / run?

A The output of above code will be

Trang 6

A Throwing exceptions is expensive Do not use exceptions to control application flow If you can

reasonably expect a sequence of events to happen in the normal course of running code, you probablyshould not throw any exceptions in that scenario

B You should never catch System.Exception or System.SystemException in a catch block because you could inadvertently hide run-time problems like Out Of Memory

C Do not catch exceptions that you do not know how to handle and then fail to propagate the exception

Trang 7

Question 9 of 20 5.0/ 5.0 PointsWhat wrong with these code :

What wrong with this code

static void ProductExists( string ProductId)

{ // search for Product

if ( dr.Read(ProductId) ==0 )

// no record found, ask to create

Trang 8

C Throwing exceptions is expensive Do not use exceptions to control application flow If you can

reasonably expect a sequence of events to happen in the normal course of running code, you probablyshould not throw any exceptions in that scenario

Trang 10

A catch clause may catch exception of which type?

A The Error Type

B The Exception Type

C The Throwable Type

Exception objects are derived from the class

Trang 12

Part 2 of 2 - Part 2 20.0/ 25.0 Points

Select a collection type that match all condition bellow :

Represents a collection of key/value pairs that are organized based on the hash code of the key

A weakly typed collection of key-value pairs

Lets you quickly get an object out of the collection by using it's key

Access items in your weakly typed collection, based on a key, not on an index

Each element is a key/value pair stored in a DictionaryEntry object

A HashTable Class

Trang 13

B Queue Class

C Stack Class

D Array class

Select a collection type that match all condition bellow :

It is One of the most basic collection classes

It's not really a collection class, due to its limitations and its not even located in the System.Collections namespace, but in the System namespace

It has a fixed size

it can have multiple dimensions

You can access an item of it by it's index

A Array class

B HashTable Class

C Queue Class

Trang 14

D Stack Class

Select a collection type that match all condition bellow :

A SortedList object internally maintains two arrays to store the elements of the list; that is, one array for the keys and another array for the associated values

Each element is a key/value pair that can be accessed as a DictionaryEntry object

A key cannot be a null reference, but a value can be

The elements of a SortedList object are sorted by the keys

In either case, a SortedList does not allow duplicate keys

When an element is added, it is inserted into SortedList in the correct sort order, and the indexing adjusts accordingly

Trang 15

How can you sort the elements of the array in descending order?

A By calling Sort() and then Reverse() methods

Trang 16

A Finally block is used to enclose code that needs to run, regardless of whether an exception is raised

Trang 17

B Finally block is executed only when no error occurs

C Finally block will be executed only if an error occurs

D Finally block is executed after Catch block when no error occurs

What will be the output of above code when compiled / run?

A The output of above code will be

99953

1.3433E+35

B The output of above code will be

99953

Trang 20

C Do Not Catch Exceptions That You Cannot Handle

Trang 21

}

A Throwing exceptions is expensive Do not use exceptions to control application flow If you can

reasonably expect a sequence of events to happen in the normal course of running code, you probablyshould not throw any exceptions in that scenario

B You should never catch System.Exception or System.SystemException in a catch block because you could inadvertently hide run-time problems like Out Of Memory

C Do not catch exceptions that you do not know how to handle and then fail to propagate the exception

Trang 22

B This code is not good, you should Use validation code to avoid unnecessary exceptions

C no thing wrong!

D Do Not Catch Exceptions That You Cannot Handle

What wrong with this code

static void ProductExists( string ProductId)

{ // search for Product

Trang 23

C Throwing exceptions is expensive Do not use exceptions to control application flow If you can

reasonably expect a sequence of events to happen in the normal course of running code, you probablyshould not throw any exceptions in that scenario

Trang 24

A Try

B Exception

C Catch

D finally

Trang 25

Question 13 of 20 5.0/ 5.0 Points

A catch clause may catch exception of which type?

A The Error Type

B The Exception Type

C The Throwable Type

Trang 26

Select a collection type that match all condition bellow :

It is One of the most basic collection classes

It's not really a collection class, due to its limitations and its not even located in the System.Collections namespace, but in the System namespace

It has a fixed size

it can have multiple dimensions

You can access an item of it by it's index

Trang 28

Question 18 of 20 5.0/ 5.0 PointsSelect a collection type that match all condition bellow :

Represents a collection of key/value pairs that are organized based on the hash code of the key

A weakly typed collection of key-value pairs

Lets you quickly get an object out of the collection by using it's key

Access items in your weakly typed collection, based on a key, not on an index

Each element is a key/value pair stored in a DictionaryEntry object

Select a collection type that match all condition bellow :

it is implemented as a circular buffer

It follows LIFO (last in first out ) system

it is a weakly typed collection

Push method allows you to add items to it

Peek method just gets the last object of it

Trang 29

Pop method also get the last object and then removes that item from it

Select a collection type that match all condition bellow :

It is useful for storing messages in the order they were received for sequential processing

it maintains FIFO (first in first out) system

With it you can create weakly typed collections that are ordered by the order they are added to the collection

It accepts a null reference as a valid value and allows duplicate elements

Objects stored in it are inserted at one end and removed from the other

A Queue Class

B Array class

Trang 31

A Finally block is used to enclose code that needs to run, regardless of whether an exception is raised

B Finally block is executed only when no error occurs

C Finally block will be executed only if an error occurs

Trang 32

D Finally block is executed after Catch block when no error occurs

What will be the output of above code when compiled / run?

A The output of above code will be

Trang 33

Question 5 of 20 5.0/ 5.0 PointsWhat is the output ? :

Trang 35

A Throwing exceptions is expensive Do not use exceptions to control application flow If you can

reasonably expect a sequence of events to happen in the normal course of running code, you probablyshould not throw any exceptions in that scenario

B You should never catch System.Exception or System.SystemException in a catch block because you could inadvertently hide run-time problems like Out Of Memory

Trang 36

C Do not catch exceptions that you do not know how to handle and then fail to propagate the exception

Trang 37

Question 10 of 20 0.0/ 5.0 PointsWhat wrong with this code

static void ProductExists( string ProductId)

{ // search for Product

C Throwing exceptions is expensive Do not use exceptions to control application flow If you can

reasonably expect a sequence of events to happen in the normal course of running code, you probablyshould not throw any exceptions in that scenario

Trang 39

_ block is executed after try block regardless of the occurrence of error _ block contains all cleanup codes For example, if there is no need of open connection to the database after try block we can write code for connection close in _ block

A catch clause may catch exception of which type?

A The Error Type

B The Exception Type

C The Throwable Type

Trang 40

Question 14 of 20 5.0/ 5.0 PointsException objects are derived from the class

Trang 41

D Try

Select a collection type that match all condition bellow :

It is One of the most basic collection classes

It's not really a collection class, due to its limitations and its not even located in the System.Collections namespace, but in the System namespace

It has a fixed size

it can have multiple dimensions

You can access an item of it by it's index

Trang 42

A SortedList object internally maintains two arrays to store the elements of the list; that is, one array for the keys and another array for the associated values

Each element is a key/value pair that can be accessed as a DictionaryEntry object

A key cannot be a null reference, but a value can be

The elements of a SortedList object are sorted by the keys

In either case, a SortedList does not allow duplicate keys

When an element is added, it is inserted into SortedList in the correct sort order, and the indexing adjusts accordingly

Select a collection type that match all condition bellow :

it is implemented as a circular buffer

It follows LIFO (last in first out ) system

it is a weakly typed collection

Push method allows you to add items to it

Trang 43

Peek method just gets the last object of it

Pop method also get the last object and then removes that item from it

Trang 44

D Arraytosort.Array.Sort()

Select a collection type that match all condition bellow :

It is useful for storing messages in the order they were received for sequential processing

it maintains FIFO (first in first out) system

With it you can create weakly typed collections that are ordered by the order they are added to the collection

It accepts a null reference as a valid value and allows duplicate elements

Objects stored in it are inserted at one end and removed from the other

A Queue Class

B Array class

C Stack Class

D HashTable Class

Ngày đăng: 31/03/2017, 15:10

TỪ KHÓA LIÊN QUAN

w