Week 12 Flashcards

1
Q

o Char[] characters = { ‘A’, ‘B’, ‘C’ } This array is less an “array of chars” it’s an

A

 A reference to an array object, with elements of char datatype that each store one char

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

o String[] strings = {‘A’, ‘B’, ‘C’} This array is less of an “array of strings” it’s

A

 A reference to an array object, with elements of reference type, and each element stores one reference to a string object

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

 T/F – Elements in an array can be of the programmers created reference type (object), such as Apple[] apples = new Apple[3]

A

True

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

o You can create new objects inside of array ___________ _____ , allowing the objects in sequential order to slot into index 1,2,3 and so

A

 Initializer lists, relating back to the issue with parallel arrays

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

o There are 2 ways to call methods on objects that are referenced inside of an array

A

 1. Call the method using the array name and subscript ie. Apples[0].getVar
 2. Copy the reference into a variable, to make it easier to understand
ie. Apple myApple = Apples[0] myApple.setVar

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

o the String[] in method main

A

 indicates it is an array of references to string objects

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

o 3 notable things about args

A

 just an identifier, that is called args by convention
 Any identifier will work
 It’s also a reference variable, that references an array object, that has in each element a reference to a string object

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

o In cmd, “java” + any argument afterwards

A

 Is placed into an array , with the left-most argument placed at 0. Each argument is treated as a string.

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

o Checking for ____ first is a defensive programming technique

A

 null

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
  • By-Value versus By-Reference
A

 By value: passing an entire copy. By reference: making an alias to the memory location of something

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

o Does java allow By value+ By reference?

A

 Java only uses By-value

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

o What is the value of a reference type?

A

 A reference value, not a copy

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

o Arrays are a _________ type

A

 A reference type

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

o Do not directly access values in an array with a custom object and then return a reference to the array

A

JUST DONT DO IT

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