nerdexam
Exams1Z0-803Questions#239
Oracle

1Z0-803 · Question #239

1Z0-803 Question #239: Real Exam Question with Answer & Explanation

The correct answer is A: sb.insert(0,"Hello ");. The java.lang.StringBuilder.insert(int offset, char c) method inserts the string representation of the char argument into this sequence. The second argument is inserted into the contents of this sequence at the position indicated by offset. The length of this sequence increases b

Question

Given the code fragment: StringBuilder sb = new StringBuilder ( ) ; Sb.append ("world"); Which code fragment prints Hello World?

Options

  • Asb.insert(0,"Hello ");
  • Bsb.append(0,"Hello ");
  • Csb.add(0,"Hello ");
  • Dsb.set(0,"Hello ");

Explanation

The java.lang.StringBuilder.insert(int offset, char c) method inserts the string representation of the char argument into this sequence. The second argument is inserted into the contents of this sequence at the position indicated by offset. The length of this sequence increases by one.The offset argument must be greater than or equal to 0, and less than or equal to the length of this sequence.

Community Discussion

No community discussion yet for this question.

Full 1Z0-803 Practice