CP212 - VBA Final Exam Questions With Correct
Answers
What |are |the |3 |rules |of |working |with |arrays? |- |CORRECT |ANSWER✔✔-1. |You |must |indicate |a |
base |type |for |the |array |
2. |You |must |indicate |the |number |of |elements |in |the |array |
3. |You |must |indicate |what |index |you |want |to |begin |with
What |is |the |default |first |index |of |an |array? |- |CORRECT |ANSWER✔✔-0
What |is |the |option |based |statement? |- |CORRECT |ANSWER✔✔-A |statement |that |lets |you |
change |the |base |(first) |index |of |the |array |
ex. |Option |Base |1 |changes |the |first |index |to |1
Where |should |the |option |based |statement |be |placed? |- |CORRECT |ANSWER✔✔-At |the |top |of |
each |module
What |are |two |ways |of |overriding |the |0-based |indexing |of |an |array? |- |CORRECT |ANSWER✔✔-1.
|Using |an |option |based |statement |
2. |Explicitly |declaring |how |the |array |will |be |indexed |
ex. |Dim |employee |(1 |to |100) |as |String
How |many |elements |will |you |get |if |you:
,- |do |not |use |option |base |1 |
- |declare |an |array |as |"salary(100)" |- |CORRECT |ANSWER✔✔-101
How |can |you |declare |an |array |with |an |unknown |size? |- |CORRECT |ANSWER✔✔-Declare |that |
you |need |an |array. |In |the |Dim |statement, |put |empty |parentheses |next |to |the |variable |name |
ex. |Dim |employee() |as |String
How |many |times |can |you |use |Redim |to |readjust |the |size |of |the |array? |- |CORRECT |
ANSWER✔✔-As |many |times |as |you |like
ex. |Redim |employee |(1 |to |nEmployees)
What |2 |things |happen |when |you |use |the |Redim |statement? |- |CORRECT |ANSWER✔✔-1. |The |
size |of |the |array |is |adjusted
2. |The |previous |contents |of |the |array |are |deleted?
How |can |you |override |the |default |behaviour |of |Redim |which |deletes |the |array |contents? |- |
CORRECT |ANSWER✔✔-Using |the |keyword |preserve |
ex. |Redim |Preserve |employee |(1 |to |nEmployees)
Do |you |need |to |declare |the |number |of |each |element |when |working |with |multidimensional |
arrays? |- |CORRECT |ANSWER✔✔-Yes
ex. |Dim |employee |(1 |to |10, |1 |to |100) |As |String
, What |does |the |keyword |Array |(the |Array |function) |do? |- |CORRECT |ANSWER✔✔-Used |to |
populate |the |list |with |variables |that |are |in |the |Array |parameters |
ex. |days |= |Array("Mon","Tue","Wed")
What |must |the |array |variable |be |declared |as |in |order |to |use |the |Array |keyword? |- |CORRECT |
ANSWER✔✔-Variant
What |does |it |mean |if |a |sub |is |public? |- |CORRECT |ANSWER✔✔-Any |other |sub |in |the |entire |
project |can |call |the |sub
What |does |it |mean |if |a |sub |is |private? |- |CORRECT |ANSWER✔✔-The |sub |is |only |callable |within |
its |module
What |are |the |3 |reasons |as |to |why |long |subs |are |bad? |- |CORRECT |ANSWER✔✔-1. |Hard |to |read
|
2. |Hard |to |debug |
3. |Difficult |to |reuse |code |in |other |programs
What |are |modularizing |programs? |- |CORRECT |ANSWER✔✔-Programs |with |a |sequence |of |
relatively |short |subs, |each |of |which |performs |a |specific |task
What |are |the |3 |advantages |to |modularizing |programs? |- |CORRECT |ANSWER✔✔-1. |Easier |to |
read |
2. |Easy |to |debug |
3. |More |likely |able |to |be |used |in |other |programs
Do |you |need |to |use |the |keyword |Call |to |invoke |another |sub? |- |CORRECT |ANSWER✔✔-No
Answers
What |are |the |3 |rules |of |working |with |arrays? |- |CORRECT |ANSWER✔✔-1. |You |must |indicate |a |
base |type |for |the |array |
2. |You |must |indicate |the |number |of |elements |in |the |array |
3. |You |must |indicate |what |index |you |want |to |begin |with
What |is |the |default |first |index |of |an |array? |- |CORRECT |ANSWER✔✔-0
What |is |the |option |based |statement? |- |CORRECT |ANSWER✔✔-A |statement |that |lets |you |
change |the |base |(first) |index |of |the |array |
ex. |Option |Base |1 |changes |the |first |index |to |1
Where |should |the |option |based |statement |be |placed? |- |CORRECT |ANSWER✔✔-At |the |top |of |
each |module
What |are |two |ways |of |overriding |the |0-based |indexing |of |an |array? |- |CORRECT |ANSWER✔✔-1.
|Using |an |option |based |statement |
2. |Explicitly |declaring |how |the |array |will |be |indexed |
ex. |Dim |employee |(1 |to |100) |as |String
How |many |elements |will |you |get |if |you:
,- |do |not |use |option |base |1 |
- |declare |an |array |as |"salary(100)" |- |CORRECT |ANSWER✔✔-101
How |can |you |declare |an |array |with |an |unknown |size? |- |CORRECT |ANSWER✔✔-Declare |that |
you |need |an |array. |In |the |Dim |statement, |put |empty |parentheses |next |to |the |variable |name |
ex. |Dim |employee() |as |String
How |many |times |can |you |use |Redim |to |readjust |the |size |of |the |array? |- |CORRECT |
ANSWER✔✔-As |many |times |as |you |like
ex. |Redim |employee |(1 |to |nEmployees)
What |2 |things |happen |when |you |use |the |Redim |statement? |- |CORRECT |ANSWER✔✔-1. |The |
size |of |the |array |is |adjusted
2. |The |previous |contents |of |the |array |are |deleted?
How |can |you |override |the |default |behaviour |of |Redim |which |deletes |the |array |contents? |- |
CORRECT |ANSWER✔✔-Using |the |keyword |preserve |
ex. |Redim |Preserve |employee |(1 |to |nEmployees)
Do |you |need |to |declare |the |number |of |each |element |when |working |with |multidimensional |
arrays? |- |CORRECT |ANSWER✔✔-Yes
ex. |Dim |employee |(1 |to |10, |1 |to |100) |As |String
, What |does |the |keyword |Array |(the |Array |function) |do? |- |CORRECT |ANSWER✔✔-Used |to |
populate |the |list |with |variables |that |are |in |the |Array |parameters |
ex. |days |= |Array("Mon","Tue","Wed")
What |must |the |array |variable |be |declared |as |in |order |to |use |the |Array |keyword? |- |CORRECT |
ANSWER✔✔-Variant
What |does |it |mean |if |a |sub |is |public? |- |CORRECT |ANSWER✔✔-Any |other |sub |in |the |entire |
project |can |call |the |sub
What |does |it |mean |if |a |sub |is |private? |- |CORRECT |ANSWER✔✔-The |sub |is |only |callable |within |
its |module
What |are |the |3 |reasons |as |to |why |long |subs |are |bad? |- |CORRECT |ANSWER✔✔-1. |Hard |to |read
|
2. |Hard |to |debug |
3. |Difficult |to |reuse |code |in |other |programs
What |are |modularizing |programs? |- |CORRECT |ANSWER✔✔-Programs |with |a |sequence |of |
relatively |short |subs, |each |of |which |performs |a |specific |task
What |are |the |3 |advantages |to |modularizing |programs? |- |CORRECT |ANSWER✔✔-1. |Easier |to |
read |
2. |Easy |to |debug |
3. |More |likely |able |to |be |used |in |other |programs
Do |you |need |to |use |the |keyword |Call |to |invoke |another |sub? |- |CORRECT |ANSWER✔✔-No