Quiz 2: Methods

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Which of the following is true about method return statements?

A method can hold multiple return statements, but only one return statement executes in one method call.

Find the output generated by the following statement. System.out.printf("Euler's number = %.3f", 2.7182818);

Euler's number = 2.718

After the keywords public static, what are the names (in order) of the parts of the following method header? public static int methodName(double num)

Return type, method name, parameter variable type, parameter variable name

Which of the following statements about variables is true?

The same variable name can be used in two different methods.

Find the output when we execute the code in the main method. Circle your answer. public static int methodOne(int x){ return (x + 1) % 4;} public static int methodTwo(int z) { return methodOne(z) * 2; } public static void main(String[] args) { int a = methodOne(5); int b = methodTwo(methodOne(6)); System.out.println("a = " + a); System.out.println("b = " + b); }

a= 1 b= 2


Kaugnay na mga set ng pag-aaral

Med Surge Exam 4 PrepU Questions

View Set

HeartCode BLS (American Heart Association)

View Set

Chapter 6 - Understanding Consumer and Business Markets

View Set