Results 1 to 4 of 4

Thread: returntype

  1. #1
    Junior Member
    Join Date
    Jun 2007
    Answers
    1

    returntype

    can a function return two values?


  2. #2
    Contributing Member
    Join Date
    May 2006
    Answers
    72

    Re: returntype

    No Java does not allow returning multiple values. Only one value can be returned by a method in Java. Also one more additional thing to know in Java regarding passing of value to methods is everything in Java is passed by value.


  3. #3
    Junior Member
    Join Date
    May 2007
    Answers
    15

    Re: returntype

    Not only in Java in all programming languages function returns ONLY one value.


  4. #4
    Junior Member
    Join Date
    Jun 2007
    Answers
    3

    Re: returntype

    //from one functions returning 2 values
    #include<iostream.h>
    #include<conio.h>
    int fun(int &x,int a,int b)
    {
    cout<<x<<" "<<&x<<endl;
    x=a+b;
    return a;
    }

    void main()
    {
    clrscr();
    int fun(int &x,int a,int b);
    int y=10;
    cout<<fun(y,1,2)<<endl;
    cout<<y<<" "<<&y<<endl;
    getch();
    }

    //It returns values by reference,
    //It's modifying another value. But there's return a;


  5.  Sponsored Ads
    Ad


     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact