nerdexam
Oracle

1Z0-811 · Question #25

1Z0-811 Question #25: Real Exam Question with Answer & Explanation

The correct answer is D. int sum(int[] a, b) {. See the full explanation below for the reasoning.

Question

Given the code: public class Calc { // line n1 return a + b; } public static void main (String[] args) { Calc obj = new Calc(); int c = obj.sum(10, 20); System.out.println("sum is " + c); } } Which code fragment, when inserted at line n1, enables the code to print sum is 30?

Options

  • Aint sum(a, b) {
  • Bint sum(int a, int b) {
  • Cint sum(int, int) {
  • Dint sum(int[] a, b) {

Community Discussion

No community discussion yet for this question.

Full 1Z0-811 Practice