![]() |
![]() |
|
![]() |
![]() |
|
Programmierung Rat & Tat für Programmierer |
![]() |
|
Themen-Optionen | Ansicht |
|
![]() |
#1 |
Hero
![]() Registriert seit: 04.09.2001
Beiträge: 894
|
![]() hi !
Ich lese im moment gerade eine paar prüfungsbeispiele für den MCAD. Dort gibt es folgendes Beispiel: try { Debug.WriteLine(“Inside Try”); throw(new IOException()); } catch (IOException e) { Debug.WriteLine (“IOException Caught”); } catch (Exception e) { Debug.WriteLine(“Exception Caught”); } finally { Debug.WriteLine (“Inside Finally”); } Debug.WriteLine (“After End Try”); Welche Ausgabe erzeugt der code ? A. Inside Try Exception Caught IOException Caught Inside Finally After End Try B. Inside Try Exception Caught Inside Finally After End Try C. Inside Try IOException Caught Inside Finally After End Try D. Inside Try IOException Caught Inside Finally Antowrt: D Explanation: First the try code runs. Then one single exception occurs, not two. Then the finally code is run, and not the code after finally. Reference: 70-306/70-316 Training kit, Creating an Exception handler, page 235 Incorrect Answers A: An exception can only be caught once, not twice. B: The code after finally will not be run if an exception occurs. C: The code after finally will not be run if an exception occurs. Das stimmt aber nicht ! Wenn man das Beispiel im VS.Net ausprobiert, wird der code NACH finally immer ausgeführt. Dadurch stellt sich dann aber die frage: wozu benötigt man finally überhaupt ?? Was sagt Ihr dazu ? fg -hannes |
![]() |
![]() |
![]() |
Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1) | |
|
|