nerdexam
Oracle

1Z0-815 · Question #100

What is the proper way to defined a method that take two int values and returns their sum as an int value?

The correct answer is D. int sum(int first, int second) { return first + second; }. Incorrect answers: A: no return statement

Creating and Using Methods

Question

What is the proper way to defined a method that take two int values and returns their sum as an int value?

Options

  • Aint sum(int first, int second) { first + second; }
  • Bint sum(int first, second) { return first + second; }
  • Csum(int first, int second) { return first + second; }
  • Dint sum(int first, int second) { return first + second; }
  • Evoid sum (int first, int second) { return first + second; }

How the community answered

(28 responses)
  • A
    4% (1)
  • C
    11% (3)
  • D
    82% (23)
  • E
    4% (1)

Explanation

Incorrect answers: A: no return statement

Topics

#method declaration#return type#parameters#method syntax

Community Discussion

No community discussion yet for this question.

Full 1Z0-815 Practice