PrepAway - Latest Free Exam Questions & Answers

What should you do?

You are an enterprise application developer. You are reviewing the following code segment.
(Line
numbers are included for reference only.)
01 public class MyResource: IDisposable {02 03 private bool disposed = false;04 05 public void Dispose() {06 Dispose(true);07 }08 09 private void Dispose(bool disposing) {10 if(!this.disposed) {11 if(disposing) {12 ReleaseManagedResources();13 }14 ReleaseUnmanagedResources();15 disposed = true;16 }17 }18 19 ~MyResource() {20 ReleaseManagedResources();21 ReleaseUnmanagedResources();22 }23 } You discover that the Dispose pattern is implemented incorrectly. You need to modify the code segment to ensure that the dispose pattern is implemented correctly. What should you do?

PrepAway - Latest Free Exam Questions & Answers

A.
Insert the following line of code after line 06. GC.SuppressFinalize(this); Replace lines 20 and 21 with the following line of code. Dispose(true);

B.
Insert the following line of code after line 06. GC.SuppressFinalize(this); Replace lines 20 and 21 with the following line of code. Dispose(false);

C.
Insert the following line of code after line 19. GC.SuppressFinalize(this); Replace lines 20 and 21 with the following line of code. Dispose(false);

D.
Insert the following line of code after line 19. GC.SuppressFinalize(this); Replace lines 20 and 21 with the following line of code. Dispose(true);


Leave a Reply