Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 183323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:05:43+00:00 2026-05-11T15:05:43+00:00

How is ( throw Exception ) and ( return value ) implemented in a

  • 0

How is (throw Exception) and (return value) implemented in a language such as Java or C#? I want to know the mechanism of how its support is included in a language and not just the usage of try { .... } catch (Exception) {}.

We know when we call a function i.e.

public void doSomething() {   ....   ....   return; } 

Then on the call is put on the stack and when the method returns the call to doSomething on stack pops out.

What happens in a case where the return statement returns with a value, say return 4;, the call to doSomething() on the stack pops out, and the next statement on Prog counter got processed? What happened with the returned value? Where did it get saved and how is it utilized?


Similarly in the case of an exception throw, the throw ex; statement finds on the stack the appropriate catch statement, and until it finds it, it keeps popping things out of the stack… How does this mechanism work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T15:05:43+00:00Added an answer on May 11, 2026 at 3:05 pm

    Take a look at this article and see if it helps. It talks about the SEH underpinnings of the .NET (C#) exception system.

    EDIT:

    If you are asking ‘How does calling methods with parameters and return values work in something like C# and Java’, then look at this article.

    At a really low level (what I am thinking you are asking), When you make a call to a method, you push your params onto the stack, then run the function, then pop the return value of the stack into a register and then process off of it, like the following:

    • Return from method (assembly code)
    • pop esx – Pop value off stack and store it in the EAX register
    • jz esx A01h – If the EAX register is zero, jump to this location.

    EDIT #2:

    In the case of an exception, the managed framework (Java, .NET, etc.) starts to unwind the stack one step at a time looking for a ‘catch’ or ‘finally’ block that can handle the error. It keeps doing this until it finds some block of code that can handle it or it runs out of code and just terminates the program. To understand how all this works at a stack level depends on which managed framework you are talking about, but the first article above combined with this article will give you the deeper view.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 203k
  • Answers 203k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I solved this issue. The following line of code did… May 12, 2026 at 8:32 pm
  • Editorial Team
    Editorial Team added an answer something like this should do the trick $("select").each(function() { //do… May 12, 2026 at 8:32 pm
  • Editorial Team
    Editorial Team added an answer So, this is kinda like code-golf, right? #include <stdlib.h> #include… May 12, 2026 at 8:32 pm

Related Questions

I'm trying to get my head around how type inference is implemented. In particularly,
I have been assigned a project to develop a set of classes that act
First of all, I do know about the Fisher-Yates shuffle. But lets say for
A common pattern in the .NET Framework is the TryXXX pattern (I don't know

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.