Oracle
1Z0-803 · Question #92
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
Working with Methods and Encapsulation
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
(21 responses)- B5% (1)
- D90% (19)
- E5% (1)
Explanation
Incorrect answers: A: no return statement
Topics
#method declaration#return type#method parameters
Community Discussion
No community discussion yet for this question.