• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

In c Is function calling is same as method calling in Java ?

 
Ranch Hand
Posts: 216
Tomcat Server Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I mean in java we have a concept of stack for method calling and also for local variable ?
But in c is there is also stack concept or any other concept ?
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's not clear what you're asking.

In both C and Java, invoking a "subroutine"--whether it's called a "function" or a "method" in that particular language--involves creating a stack frame for parameters, return value, and PC. The details of what goes on that stack frame and in what order are of course different. And method calling in Java involves things like polymorphism and a "current object" that don't exist in C.

I have no idea what you mean by "stack concept of any other concept".

What is it you're actually trying to understand?
 
Ranch Hand
Posts: 859
IBM DB2 Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, unless you get into pointers and pass-by-reference arguments.

Most modern and older (ala Forth) languages have a stack as a core component.

WP
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William P O'Sullivan wrote:pass-by-reference arguments.



Well, since neither C nor Java supports PBR, that bit is irrelevant.
 
Nikhil Sagar
Ranch Hand
Posts: 216
Tomcat Server Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i mean in a simple c program like this


here in this code function calling is following the concept of stack or any other concept ?
 
Nikhil Sagar
Ranch Hand
Posts: 216
Tomcat Server Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeff Verdegan wrote:It's not clear what you're asking.

In both C and Java, invoking a "subroutine"--whether it's called a "function" or a "method" in that particular language--involves creating a stack frame for parameters, return value, and PC. The details of what goes on that stack frame and in what order are of course different. And method calling in Java involves things like polymorphism and a "current object" that don't exist in C.

I have no idea what you mean by "stack concept of any other concept".

What is it you're actually trying to understand?



sorry jeff it is "stack concept or any other concept".
sorry it was my mistake.
i have edited it now.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nikhil Sagar wrote:i mean in a simple c program like this


here in this code function calling is following the concept of stack or any other concept ?



As I already stated, when you invoke those functions, a stack will be used.

 
Nikhil Sagar
Ranch Hand
Posts: 216
Tomcat Server Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay Okay jeff now i got it.
Thanks again jeff.
Thanks William.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In abstract terms, you call a function, but you invoke a method.

Functions are procedure-oriented, but methods are object-oriented. A few languages support both paradigms concurrently. The best-known of which is C++.

FORTRAN in its original form also discriminated between subroutines and functions as did some of its contemporaries and descendants. A function gets its name from its mathematical forebear, which has a range (input) and domain (output), although in architectural terms, the computer term became assigned to a subroutine (callable code procedure) that had a method of returning results. So a FORTRAN "SUBROUTINE" statement was the early version of a function returning void.

As far as stacks go, pretty much any programming language that permits recursive procedures has some sort of stack basis. FORTRAN and COBOL did not originally support recursion in their strictest forms, which was fortunate for IBM, since the System/360 and System/370 systems had no stack hardware and had to do that kind of stuff the hard way.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic