Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Explanation on a short program

BunkerHillBroad
BunkerHillBroad 


I just need a rundown on whats going on line by line for this made up java code. class fakeprob { static int foo (int a, int b) { return (a + b); } static int bar (int x) { x += 2; return (x * x); } public static void main (String [] args ) { int x = 2; System.out.println ("foo (x, 3) = " + foo (x, 3) ); System.out.println ("foo (x, 4) = " + foo (x, 4) ); System.out.println ("bar (-x) = " + bar (-x) ); System.out.println ("bar (foo (x+x, ++x) ) = " + bar (foo (x+x, ++x) ) ); System.out.println ("Final value of x = " + x ); } } Attachments
Tags Clarifications

Answers

Explanation

mariobeka
mariobeka 



In the java file you will find in comments what is happening in every line. Attachments
fakeprob.java (1 K) Download Preview
return (x * x); } // Main method public static void main (String [] args ) { int x = 2; // declaration and initialization of the variable x by 2 System.out.println ("foo (x, 3) = " + foo (x, 3) ); // prints out foo (x, 3) =

Screenshots
Purchase Answer