ShmoopTube
Where Monty Python meets your 10th grade teacher.
Search Thousands of Shmoop Videos
Computer Science Videos 112 videos
AP Computer Science 1.2 GridWorld Case Study and APIs. What is the direction of the actor?
AP Computer Science 1.4 Standard Algorithms. How many times will mystery be called for mystery(n) for n > 1?
AP Computer Science 2.3 Classes and Objects. Which of the following is correct implementation of the Country class?
AP Computer Science 4.2 Review of the Basics 186 Views
Share It!
Description:
AP Computer Science: Review of the Basics Drill 4, Problem 2. What is the output of the following code segment?
Transcript
- 00:00
Thank you We sneak And here's your smoke usually brought
- 00:05
to you by extreme couponing brought to you by coupons
- 00:09
Dot com the finest couponing site on the web You
- 00:12
never know when you'll need eighty thousand rolls of paper
- 00:14
towels Yeah you do All right What is the output
Full Transcript
- 00:20
of the following code segment Go string beyond and here
- 00:26
the potential answers Yeah All right two relatively simple lines
- 00:32
of code here The first line creates a string called
- 00:35
beyond that contains thank you The saint line prince outlines
- 00:42
his content is our beyonce string but not so fast
- 00:45
The sub string method appears to be acting on our
- 00:48
string with two parameters that's one and six yeah some
- 00:53
string is actually a very useful method for working with
- 00:56
just a section of a string by specifying starting in
- 00:59
points you can sniff out a section of string just
- 01:01
like clipping out of coupon hey free creamed corn baby
- 01:06
do parameters given to the sub string method are the
- 01:08
start and end points for our cut Well technically they're
- 01:11
referred to as the begin index and nd index and
- 01:14
in this example that begin indexes one on the end
- 01:17
index is six This question is really just a matter
- 01:20
of figuring out where were clipping are some string in
- 01:23
java string indexes As with most computerese things counting begins
- 01:27
at zero being that bee is the first character and
- 01:31
thus zero will begin clipping after be at why there
- 01:36
All right our end indexes six but in the business
- 01:39
of indexes we only go up to the end index
- 01:41
and do not included So we'll move along over like
- 01:45
this up to six but without including it and there
- 01:48
we have it that's what will be displayed thanks to
- 01:50
the sub string method and looking at a possible answer
- 01:53
these match answers a c and he all contained the
- 01:56
b of ours They're obviously trying to trick those of
- 01:59
us who fail to remember that index counting begins at
- 02:02
zero rather than one try Guys Answer b was also
- 02:06
being sneaky It starts counting in the right spot but
- 02:08
it includes one too many characters at the end remember
- 02:11
that we don't include the end index character in the
- 02:14
substrate We only go up to it though did it 00:02:16.43 --> [endTime] is and in a reserve
Related Videos
AP Computer Science 1.2 GridWorld Case Study and APIs. What is the direction of the actor?
AP Computer Science 1.4 Standard Algorithms. How many times will mystery be called for mystery(n) for n > 1?
AP Computer Science 2.3 Classes and Objects. Which of the following is correct implementation of the Country class?
AP Computer Science 3.4 Inheritance, Abstraction, and Polymorphism. Which of the following will satisfy the conditional if statement for boo, str,...
AP Computer Science 4.2 Standard Algorithms. What kind of algorithm is the following?