CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Interview Success Kit - Get Success in Job Interviews Interview Success Kit - 30,000 Interview Que. & Ans.
Covers 30,000+ Interview Questions asked in actual MNC Interviews - all with model answers.
Get Your Dream Job Now - www.vyoms.com
Sponsored Links
Interview Questions
Our Services

INTERVIEW QUESTIONS MICROSOFT DOTNET DETAILS
Question :
Why is catch(Exception) almost always a bad idea?
Category DotNet Interview Questions
Rating (3.7) By 63 users
Added on 12/21/2010
Views 2025
Rate it!
Answers:

Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project.



Hi, Catch(System.Exception) is not a bad idea to use. Catch(Exception) means handling all types of errors that are thrown by the Try block. I think even throw Exception is not a bad idea to use in the Catch(Exception)to maintain stack trace.



Posted by: Pavan

Contact Pavan Contact Pavan

Hi,catch cannot be used whille debuging asp.net code as the particular error is thrown and handled by catch.
but after debuging we should apply catch ..



Posted by: shanky

Contact shanky Contact shanky

If we use multiple catches(Bcz all the exceptions are came there when the exceptions were found) means it could be a useful thing otherwise i think it is a bad one.



Posted by: Suresh.K

Contact Suresh.K Contact Suresh.K

Hi,
Catch(Exception) is used when you are not sure that which exception will be thrown by the code. This syntax will handle all system define exception. But bad side of using this syntax is that it slowdowns the execution speed as CLR have to check each possible exception.



Posted by: ankur

Contact ankur Contact ankur

catch(Exception) is a bad idea, because, in a code block we know what we written and each code line has its own exception returns, so it should be of those types. Instead of catch(Exception) we can do multiple catch blocks with their exception types.



Posted by: Nagaraj

Contact Nagaraj Contact Nagaraj

exception affects the execution speed. so maximum try to avoid exception.



Posted by: selvasundar

Contact selvasundar Contact selvasundar

If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
  • Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification Enter the above shown code: *
    Inform me about updated answers to this question

    Related Questions
    View Answer
    What is FullTrust? Do GAC?ed assemblies have FullTrust?
    View Answer
    What are PDBs? Where must they be located for debugging to work?
    View Answer
    What is strong-typing versus weak-typing? Which is preferred? Why?
    View Answer
    What is the difference between thread and process?
    View Answer
    What is the difference between a.Equals(b) and a == b?
    View Answer
    How does the lifecycle of Windows services differ from Standard EXE?
    View Answer
    What is a Windows Service and how does its lifecycle differ from a ?standard? EXE?
    View Answer
    What is CLR?
    View Answer
    Explain the differences between Server-side and Client-side code?
    View Answer
    What type of code (server or client) is found in a Code-Behind class?
    View Answer
    Should validation (did the user enter a real date) occur server-side or client-side? Why?
    View Answer
    What does the EnableViewState Means?
    View Answer
    What is the difference between Servers? Transfer and Response. Redirect? Why would I choose one over the other?
    View Answer
    Can you give an example of when it would be appropriate to use a web service as opposed to a non-serviced .NET component
    View Answer
    Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?
    View Answer
    Can you give an example of what might be best suited to place in the Application Start and Session Start subroutines?
    View Answer
    What are ASP.NET Web Forms? How is this technology different than what is available though ASP (1.0-3.0)?
    View Answer
    How does VB.NET/C# achieve polymorphism?
    View Answer
    How would you implement inheritance using VB.NET/C#?
    View Answer
    Whats an assembly ..?
    View Answer

    Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

    View ALL DotNet Interview Questions & Answers

    User Options
    Latest 20 Questions
    How to Retrieve a Cookie Value ?
    How to Create a Cookie?
    What is ViewState ?
    What are different methods of session maintenance in ASP.NET?
    What is cross cutting concern and concern in spring AOP ?
    What are the important beans lifecycle methods ?
    Explain the advantages of using DAO module?
    What is SQLProvider ?
    How struts application can be integrated with spring?
    What are the advantages of spring framework?
    What is ?Throws advice? in Spring ?
    What is Metadata Autoproxying ?
    Describe about DAO in Spring framework ?
    What is called an Advice ?
    What is IOC?
    What are the types of Dependency Injection?
    What are the different Modes of Autowiring ?
    Define Application context module?
    Why Spring framework is needed?
    What is called Spring MVC?


    Copyright ©2003-2016 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions

    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | C Interview Questions & Answers

    Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes


    Cache = 0.015625 Seconds