Inside main
Inside FUNCTION_1
About to call funct2
Inside FUNCTION_2with param 8
FUNCTION_2returned a value of 16
About to call FUNCTION_2again
Inside FUNCTION_2with param -3
FUNCTION_2returned a value of -6
Also, how come every time you mention a function by name, you forget to put a space after it? Every single time. It's weird. And then there's that one time where you called FUNCTION_2 "funct2" for some reason. Not sure what's up with that.
I just started learning AP computer, and having a hard time figuring out the outcome, please help me out.
Example 1:
public class FunctionCall
{
public static void FUNCTION_1()
{
System.out.println ("Inside FUNCTION_1");
}
public static void main (String[] args)
{
int val;
System.out.println("Inside main");
FUNCTION_1();
System.out.println("About to call funct2");
val = FUNCTION_2(8);
System.out.println("FUNCTION_2returned a value of " + val);
System.out.println("About to call FUNCTION_2again");
val= FUNCTION_2 (-3);
System.out.println("FUNCTION_2returned a value of "+val);
}
public static int FUNCTION_2 (int param)
{
System.out.println("Inside FUNCTION_2with param " + param);
return param*2;
}
}