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

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

Part of - Part Question of 20 65.0/ 75.0 Points 5.0/ 5.0 Points The _ encloses the statements that might throw an exception whereas catch handles an exception if one exists A Try B Catch C Finally D Exception Question of 20 A block enclose the code that could throw an exception A Exception B Error 5.0/ 5.0 Points C Catch D Try Question of 20 5.0/ 5.0 Points Sam is developing an application that enables the users to perform read and write operations on text tiles He uses structured exception handling to handle the errors He writes the code for closing all the files that were opened in the finally block Which of the following is true regarding the finally block? 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 Question of 20 using System; class Test { public static void Main() 0.0/ 5.0 Points { int value =Int32.Parse(""99953""); double dval=Double.Parse(""1.3433E+35""); Console.WriteLine(value); Console.WriteLine(dval); } }; 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 1.3433E35 C The code will not generate a compile time error D The code will generate a compile time error Question of 20 What is the output ? : class Program { static void Main(string[] args) { int number = 1; 5.0/ 5.0 Points try { number = 2; return; } catch (Exception) { } finally { number = 3; } Console.WriteLine(number); Console.ReadLine(); } } A B C D nothing Question of 20 What wrong with these code : try 5.0/ 5.0 Points { intNumber = int.Parse(strNumber); } catch (Exception ex) { Console.WriteLine(""Can't convert the string to "" + ""a number: "" + ex.Message); } A You should catch System.Exception or System.SystemException in a catch block because you could inadvertently hide run-time problems like Out Of Memory B no thing wrong! C Do Not Catch Exceptions That You Cannot Handle D Syntax error Question of 20 A method _an exception when that method detects that a problem has occured A Trys B Throws 5.0/ 5.0 Points C Catches D a and b Question of 20 5.0/ 5.0 Points What wrong with this code try { // exception generating code } catch(Exception e) { // Do nothing } 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 probably should 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 not know how to handle and then fail to propagate the exception Question of 20 5.0/ 5.0 Points What wrong with these code : double result = 0; try { result = numerator/divisor; } catch( System.Exception e) { result = System.Double.NaN; } A Syntax error 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 Question 10 of 20 What wrong with this code static void ProductExists( string ProductId) { // search for Product if ( dr.Read(ProductId) ==0 ) // no record found, ask to create 5.0/ 5.0 Points { throw( new Exception(""Product Not found"")); } } A Do not catch exceptions that you not know how to handle and then fail to propagate the exception 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 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 probably should not throw any exceptions in that scenario Question 11 of 20 What is the output : class Program { static void Main(string[] args) { int number = 0; try { number = number++; } catch (Exception) { number++; 0.0/ 5.0 Points } finally { number++; } Console.WriteLine(number); Console.ReadLine(); } } A B Syntax error C D Question 12 of 20 5.0/ 5.0 Points _ 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 Try B Exception C Catch D finally 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 Question 14 of 20 Exception objects are derived from the class 5.0/ 5.0 Points C Stack Class D HashTable Class Part of - Part Question of 20 50.0/ 75.0 Points 5.0/ 5.0 Points The _ encloses the statements that might throw an exception whereas catch handles an exception if one exists A Try B Catch C Finally D Exception Question of 20 A block enclose the code that could throw an exception 5.0/ 5.0 Points A Exception B Error C Catch D Try Question of 20 5.0/ 5.0 Points Sam is developing an application that enables the users to perform read and write operations on text tiles He uses structured exception handling to handle the errors He writes the code for closing all the files that were opened in the finally block Which of the following is true regarding the finally block? 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 Question of 20 using System; class Test { public static void Main() { int value =Int32.Parse(""99953""); double dval=Double.Parse(""1.3433E+35""); Console.WriteLine(value); Console.WriteLine(dval); } }; 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 1.3433E35 C The code will not generate a compile time error D The code will generate a compile time error 0.0/ 5.0 Points Question of 20 What is the output ? : class Program { static void Main(string[] args) { int number = 1; try { number = 2; return; } catch (Exception) { } finally { number = 3; } Console.WriteLine(number); Console.ReadLine(); } } A B C 5.0/ 5.0 Points D nothing Question of 20 0.0/ 5.0 Points What wrong with these code : try { intNumber = int.Parse(strNumber); } catch (Exception ex) { Console.WriteLine(""Can't convert the string to "" + ""a number: "" + ex.Message); } A You should catch System.Exception or System.SystemException in a catch block because you could inadvertently hide run-time problems like Out Of Memory B no thing wrong! C Do Not Catch Exceptions That You Cannot Handle D Syntax error Question of 20 A method _an exception when that method detects that a problem has occured 5.0/ 5.0 Points A Trys B Throws C Catches D a and b Question of 20 0.0/ 5.0 Points What wrong with this code try { // exception generating code } catch(Exception e) { // Do nothing } 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 probably should 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 not know how to handle and then fail to propagate the exception Question of 20 5.0/ 5.0 Points What wrong with these code : double result = 0; try { result = numerator/divisor; } catch( System.Exception e) { result = System.Double.NaN; } A Syntax error 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 Question 10 of 20 0.0/ 5.0 Points What wrong with this code static void ProductExists( string ProductId) { // search for Product if ( dr.Read(ProductId) ==0 ) // no record found, ask to create { throw( new Exception(""Product Not found"")); } } A Do not catch exceptions that you not know how to handle and then fail to propagate the exception 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 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 probably should not throw any exceptions in that scenario Question 11 of 20 What is the output : class Program { static void Main(string[] args) { int number = 0; 0.0/ 5.0 Points try { number = number++; } catch (Exception) { number++; } finally { number++; } Console.WriteLine(number); Console.ReadLine(); } } A B Syntax error C D Question 12 of 20 5.0/ 5.0 Points _ 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 Try B Exception C Catch D finally Question 13 of 20 A catch clause may catch exception of which type? A The Error Type B The Exception Type C The Throwable Type 5.0/ 5.0 Points Question 14 of 20 5.0/ 5.0 Points Exception objects are derived from the class A Event B Catch C Exception D Try Question 15 of 20 A block enclose the code that could throw an exception A Error B Catch C Exception 5.0/ 5.0 Points D Try Part of - Part 15.0/ 25.0 Points Question 16 of 20 5.0/ 5.0 Points 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 D Stack Class Question 17 of 20 Select a collection type that match all condition bellow : 5.0/ 5.0 Points 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 A Queue Class B SortedList Class C Array class D HashTable Class Question 18 of 20 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 0.0/ 5.0 Points 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 19 of 20 The Syntax of a predefined Sort method is: A System.Array.Sort(Arraytosort) B System.Array.Sort() C Arraytosort.Sort() 5.0/ 5.0 Points D Arraytosort.Array.Sort() Question 20 of 20 0.0/ 5.0 Points 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 ... an exception whereas catch handles an exception if one exists A Try B Catch C Finally D Exception Question of 20 5.0/ 5.0 Points A block enclose the code that could throw an exception A Exception. .. an exception whereas catch handles an exception if one exists A Try B Catch C Finally D Exception Question of 20 A block enclose the code that could throw an exception 5.0/ 5.0 Points A Exception. .. B Exception C Catch D finally 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 Question 14 of 20 Exception

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

Xem thêm: 05 BTNB quiz3 exception handling utilities

TỪ KHÓA LIÊN QUAN

w