ShmoopTube

Where Monty Python meets your 10th grade teacher.

Search Thousands of Shmoop Videos


Computer Science Videos 112 videos

AP Computer Science 1.1 Classes and Objects
468 Views

AP Computer Science: Classes and Objects Drill 1, Problem 1. Which of the following is a correct {/* Implementation */} for the isInsect method?

AP Computer Science 1.2 GridWorld Case Study and APIs
493 Views

AP Computer Science 1.2 GridWorld Case Study and APIs. What is the direction of the actor?

AP Computer Science 1.3 Classes and Objects
245 Views

AP Computer Science 1.3 Classes and Objects. Which of the following should be declared as a static variable?

See All

AP Computer Science 2.5 Standard Data Structures 172 Views


Share It!


Description:

AP Computer Science 2.5 Standard Data Structures. Which of the following correctly declares and fills a String array of length 3?

Language:
English Language

Transcript

00:00

Thank you We sneak Then here's your shmoop du jour

00:05

brought to you by build it yourself furniture you'll save

00:08

a little money but make up the difference in agonizing

00:12

screams late into the night which of the following correctly

00:15

declares and fills a string array of length Three and

00:19

here your potential answers exacts guy next time All right

00:26

the old question about declaring and populating in array have

00:29

been asking that since caveman days well in this case

00:32

it's an array of strings There are three small steps

00:36

involved to get such a thing up and running the

00:38

first two steps there declaring a variable to refer to

00:40

an array and then allocating memory to hold the values

00:44

And there are two ways to do that little dance

00:47

either on one line or two Much of the official

00:50

Job documentation uses the 2 line method because it's a

00:52

teeny tiny bit more flexible by separating the variable declaration

00:56

from memory allocation you can hold off with a second

00:59

line and allocate memory only once you need it For

01:02

most objects it'll never be an issue but in cases

01:05

dealing with tons of a raise or vast amounts of

01:07

data it could become a thing for these three little

01:10

strings It wouldn't matter whether we one line or two

01:13

line it but now you can build the bookshelf Sure

01:16

it took half a saturday and both thumbs got smashed

01:19

but now it can be loaded Yeah the proper way

01:22

to do so is to start a position zero and

01:24

go from there Option c andy failed to start with

01:27

zero and jump right toe one which is enough to

01:30

cause your program Teo flip it's wig interestingly enough sandy

01:33

get the first part Correct They each properly declared their

01:36

variable and allocate memory using the one into line methods

01:39

but goof it on the follow through with that starting

01:42

at one business Yeah did more option a doesn't do

01:45

it quite right In fact it watches the declaring process

01:48

quite a bit it's attempting to be some weird combination

01:51

of allocating and declaring but without specifying the new operators

01:55

So not gonna fly option e look closely It's attempting

01:59

the two linemen method but it's not declaring an array

02:02

There are no brackets after string So rather than getting

02:05

an array of strings we just get a single string

02:08

The next line where Is made into a new array

02:10

of size Three just isn't going to mess with that

02:13

option B is where it's at a rave strings a

02:16

equals new string array of size three Then it properly

02:19

loads it full of stuff and we can wait Oh 00:02:24.368 --> [endTime] there should be a receipt around here somewhere

Related Videos

AP Computer Science 1.2 GridWorld Case Study and APIs
493 Views

AP Computer Science 1.2 GridWorld Case Study and APIs. What is the direction of the actor?

AP Computer Science 1.4 Standard Algorithms
200 Views

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
191 Views

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
204 Views

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
191 Views

AP Computer Science 4.2 Standard Algorithms. What kind of algorithm is the following?