exam questions

Exam 1z0-819 All Questions

View all questions & answers for the 1z0-819 exam

Exam 1z0-819 topic 1 question 4 discussion

Actual exam question from Oracle's 1z0-819
Question #: 4
Topic #: 1
[All 1z0-819 Questions]

Given:

What is the result?

  • A. 5
  • B. 4
  • C. 3
  • D. An exception is thrown at runtime
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
d7bb0b2
7 months ago
why 4 ? if final string is _HCOW and has 5 elements
upvoted 1 times
d7bb0b2
7 months ago
anwers: delete(2,7) delete 5 elements 2,3,4,5,6 => so 9 - 5 = 4 lol!
upvoted 1 times
...
...
james2033
9 months, 2 weeks ago
Selected Answer: B
public class Tester { public static void main(String[] args) { StringBuilder sb = new StringBuilder(5); sb.append("HOWDY"); sb.insert(0, ' '); sb.replace(3, 5, "LL"); sb.insert(6, "COW"); sb.delete(2, 7); System.out.println(sb.length()); } } Result: 4. --> Choose B.
upvoted 1 times
...
qulyt
12 months ago
Selected Answer: B
HOWDY <-- sb.append("HOWDY"); *HOWDY <-- sb.insert(0, "*"); *HOLLY <-- sb.replace(3, 5, "LL"); *HOLLYCOW <-- sb.insert(6, "COW"); *HOW <-- sb.delete(2, 7); 4 <-- sb.length();
upvoted 4 times
...
Stavok
1 year ago
Selected Answer: B
B IS CORRECT
upvoted 1 times
...
aruni_mishra
1 year, 1 month ago
B- Correct, see below with capacity also. HOWDY :: sb.length():5, sb.capacity(): 5 _HOWDY :: sb.length():6, sb.capacity(): 12 _HOLLY :: sb.length():6, sb.capacity(): 12 _HOLLYcow :: sb.length():9, sb.capacity(): 12 _How :: sb.length():4, sb.capacity(): 12
upvoted 1 times
...
Mukes877
1 year, 2 months ago
5 is correct answer because HOWDY _HOWDY _HOLLDY _HOLLDcowY _HowY 5
upvoted 1 times
...
bharathdave
1 year, 3 months ago
'-' indicates blank space HOWDY _HOWDY _HOLLY _HOLLYCOW _HOW
upvoted 2 times
bharathdave
1 year, 3 months ago
4 is the length.
upvoted 2 times
...
...
AlanRM
1 year, 3 months ago
used : sb.insert(0,' '); exit console: HOWDY HOWDY HOLLY HOLLYCOW HOLLYOW 8
upvoted 1 times
...
JGR_77
1 year, 4 months ago
D is correct: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: offset 6, length 5 at java.base/java.lang.String.checkOffset(String.java:4572) at java.base/java.lang.AbstractStringBuilder.insert(AbstractStringBuilder.java:1170) at java.base/java.lang.StringBuilder.insert(StringBuilder.java:336) at com.jgr.temporal.main.Principal.main(Principal.java:16)
upvoted 1 times
...
pikosss
1 year, 4 months ago
B is correct: the capacity will be automatically extended
upvoted 1 times
...
Ankit1010
1 year, 6 months ago
B - Correct Answer
upvoted 2 times
...
UcefSoft
1 year, 8 months ago
Selected Answer: B
B is correct
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago