answersLogoWhite

0


Best Answer

Exception is a event which can interrupt a normal flow of your program. In other way, exception is a abnormal condition which can occur during the execution of a program. Yes , we can handle exceptions through try, catch, finally, throw and throws.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

Throwing an exception means create a new exception to notify the program that a unexpected condition was occurred.

Catch an exception refers to handle that unexpected condition and allow the program continue its normal execution.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Exceptions are special errors or situations (sometimes programmer-defined) that interrupt normal program flow.

In C#, thrown exceptions will remain unhandled (and will usually give a general error message) unless handled by a try-catch block, like this:

try

{

// execute instructions that can possibly thrown an exception

}

catch (Exception ex)

{

// Here we handle the exception, using whatever we need from

// Exception object, such as ex.Message or ex.StackTrace.

}

finally

{

// This section is called regardless of whether an exception was thrown

// or not. The end result of both the try and catch blocks' execution is

// this block.

}

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Language compilers are adept at pointing out most of the erroneous code in a program, however there are some errors that only become apparent when the program is executed. Consider the code in Listing 1.1; here, the program defines a method dividethat does a simple division operation taking two integers as parameter arguments and returning the result of their division. It can safely be assumed that when the divide(4, 2)statement is called, it would return the number 2. However, consider the next statement, where the program relies upon the provided command line arguments to generate a division operation. What if the user provides the number zero (0) as the second argument? We all know that division by zero is impossible, but the compiler couldn't possibly have anticipated the user providing zero as an argument.

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

By using exception handling we can avoid unwanted unwanted results on our page. On places where we know our code may execute in an unwanted fashion, we can surround it with exception handling block to ensure that our code doesnt disrupt the application flow.

For example:

In a text field where you enter amounts and use it in our code we parse it as a number. But if the user enters any invalid numbers, while parsing an exception would be thrown and our program would terminate. We can avoid this by using the try catch block.

public int parseStringToNum(String value) {

int val;

try {

val = Integer.parseInt(value);

} catch (Exception e){

val = 0;

}

return val;

}

Here even if the value entered is invalid only a 0 will be returned and no exception would be thrown.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Exception handling helps us catch or identify abnormal scenarios in our code and handle them appropriately instead of throwing up a random error on the front-end (User Interface) of the application.

Exception handling allows developers to detect errors easily without writing special code to test return values. Even better, it lets us keep exception-handling code cleanly separated from the exception-generating code. It also lets us use the same exception-handling code to deal with a range of possible exceptions.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

special processing of unexpected events inside the program. events outside the program are processed by interrupts, not exceptions.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is exception handling in object oriented languages?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering
Related questions

How do you apply class diagram with programming languages which is not based on object-oriented like c?

You cannot. Class diagrams are only applicable to object oriented programming languages. C is not object oriented, but C++ is.


What are examples of Object Oriented programming language?

Machine code, assembly language and C are all non-object oriented programming languages. Fortran, COBOL, Pascal and BASIC were originally non-object oriented languages but there are now object-oriented variants of these languages. C++, C# and Java were all designed with object-oriented programming in mind from the outset.


Why c is object oriented programming languages?

C isn't an object oriented language... C++ is, because it has classes.


Which languages are complete Object oriented language?

C#


How do you create multiple inheritance in c?

You don't. Inheritance is a feature of object oriented programming languages. C is not object oriented.


What is AOP?

AOP or Aspect oriented Programming is A paradigm in Computer Science. In traditional object-oriented programming, common code like logging, exception handling scattered all across method, classes, object hierarchies, or even entire object models. so Aspect oriented programming is a technique to separate these concerns from real problem domain and increase modularity and reusability of program


Why java is purely object oriented programming language?

It is said that Java is not purely object-oriented, because of its handling of primitive data types. The reason for this is for efficiency.


What programming language is Microsoft Excel Programmed in?

Object-Oriented languages


What are properties in Javascript?

Like other object-oriented languages (JavaScript is technically not 'object-oriented'), JavaScript has objects, those objects have attributes or 'properties' which hold data


What are the companies which use pure object oriented programming languages?

Microsoft, Apple and so on.


What is object oriented para diagram?

There are two types of languages. Procedure oriented language and object oriented langugae. An object oriented langugae is quite impresses from real world environment. it says that for example a classroom is full with chairs then that class is a class of object oriented and those chairs are object... Basically this makes programing very easy and short... Hope this answer was of some help...


All object-oriented programming languages must have the 3 following features?

Abstraction, encapsulation and polymorphismare the three fundamental features of an object oriented programming language.