ShmoopTube
Where Monty Python meets your 10th grade teacher.
Search Thousands of Shmoop Videos
AP Computer Science A Videos 108 videos
AP Computer Science: Classes and Objects Drill 3, Problem 5. Which of the following is not an object?
AP Computer Science: Classes and Objects Drill 3, Problem 4. Which of the following are objects?
AP Computer Science 4.1 Classes and Objects. Which of the answers is the best definition of a postcondition?
AP Computer Science 4.4 Review of the Basics 181 Views
Share It!
Description:
APCS: Review of the Basics Drill 4, Problem 4. Which of the following correctly creates the string "milk"?
Transcript
- 00:00
Sorry Man here's your smoke to your reminding you that
- 00:05
there is no i in team But there is an
- 00:08
i in milk Great for the skin You should try
- 00:11
it That's Great Given the following string declaration string a
- 00:17
equals m l k which of the following correctly creates
Full Transcript
- 00:22
the string milk And here the potential answers you Well
- 00:29
this question is asking us which of the five potential
- 00:31
answers would turn mlk into milk and goes about it
- 00:35
in a couple of different potential waste the first method
- 00:38
used in options and be used the strings indexes to
- 00:42
attempt to build milk one character at a time a
- 00:45
strings index numbers are a bit like having a card
- 00:48
catalog Each string has an index beginning with zero and
- 00:51
continues counting each character until the end of the string
- 00:53
including punctuation marks in spaces The strength frogs and toads
- 00:58
for example has an index from zero to fourteen and
- 01:01
if you pulled index ten you'd get the character teeth
- 01:05
All right let's try out what options and beer proposing
- 01:08
string a mlk has an index that would look a
- 01:11
little like this if we were to visualize it option
- 01:14
a attempts to build milk by first selecting index one
- 01:18
of m l k and that's letter l so this
- 01:21
is definitely not right Option b starts with index zero
- 01:24
which is m could start that it adds the necessary
- 01:28
i and then leaps to index three and four which
- 01:33
don't exist option c thru use the sub string method
- 01:38
which uses what we already know about indexes to select
- 01:41
a range of characters from a string rather than just
- 01:44
one at a time If we wanted to grab toads
- 01:46
from frogs and toads waken use sub string method with
- 01:49
the parameters ten as they begin index and fifteen is
- 01:52
the end index so we start here and in here
- 01:55
to grab everything in that range up to fifteen still
- 01:58
it's try option c we start by grabbing the subs
- 02:01
string from index zero one which gets us the m
- 02:03
there we go remember the end index goes up to
- 02:07
but does not include the index number given that we're
- 02:10
only going up to index one here and not including
- 02:13
it so we don't get the l then we insert
- 02:17
the eye okay and insert a sub string from index
- 02:20
one two three that's l and kay and we've done
- 02:23
it We've got milk looks like cy's gonna be our
- 02:26
answer But let's look at what's wrong with dna just
- 02:28
to be sure All right Well d starts with grabbing
- 02:31
a sub string at the index is zero and zero
- 02:33
of course the end index only goes up to but
- 02:36
does not include the character reference though Starting at zero
- 02:40
and going up to zero without including it gets us
- 02:42
a whole lot of nothing No m no milk option
- 02:46
E does practically the same thing A sub string at
- 02:48
the index is one and one that starts us an
- 02:50
l here and then goes up to but does not
- 02:53
include l So again we get a whole lot of
- 02:55
nothing And option c It is chocolate chip our favorite 00:02:59.228 --> [endTime] baby Yeah
Related Videos
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 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 Standard Algorithms. What kind of algorithm is the following?