Arrays Flashcards

1
Q

What is the primary purpose of using arrays in Java?
a) To store values of different data types
b) To store multiple indexed values of the same data type
c) To handle database queries
d) To format strings

A

b) To store multiple indexed values of the same data type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which Java method splits a string into an array of substrings based on a specified delimiter?
a) split()
b) join()
c) parse()
d) substring()

A

a) split()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What type of array is ‘args’ in the main() method?
a) Integer array
b) Float array
c) String array
d) Boolean array

A

c) String array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can arguments be passed to a Java program?
a) Only from the command line
b) Only from an IDE
c) From both the command line and an IDE
d) They cannot be passed

A

c) From both the command line and an IDE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What method is used to access the length of an array in Java?
a) size()
b) getLength()
c) length()
d) arrayLength()

A

c) length()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In a two-dimensional array, what does the first index represent?
a) The row
b) The column
c) The length
d) The width

A

a) The row

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does the ‘args.length’ expression return?
a) The number of characters in the first argument
b) The number of arguments passed to the program
c) The size of the first argument
d) The total length of all arguments

A

b) The number of arguments passed to the program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In the grid example, which character represents ‘Byorki - Ranger’?
a) K
b) A
c) T
d) B

A

d) B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the purpose of the movePlayer method?
a) To move a player to a new location on the grid
b) To delete a player from the grid
c) To print the player’s current location
d) To initialize the game grid

A

a) To move a player to a new location on the grid

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

In the movePlayer method, what does ‘newY++’ do when the direction is ‘N’?
a) Moves the player south
b) Moves the player east
c) Moves the player west
d) Moves the player north

A

d) Moves the player north

How well did you know this?
1
Not at all
2
3
4
5
Perfectly