Deck 11: Object-Oriented Programming and Arrays
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/30
Play
Full screen (f)
Deck 11: Object-Oriented Programming and Arrays
1
Typically, what's the first thing you should do you in a subclass constructor?
A) Initialize the properties to 0.
B) Call the superclass constructor with this(arguments);.
C) Call the superclass constructor with super(arguments);.
A) Initialize the properties to 0.
B) Call the superclass constructor with this(arguments);.
C) Call the superclass constructor with super(arguments);.
C
2
Suppose that you have a class named Student with a method named payFees and that you have instantiated an object named student. Which of the following is a proper call to the payFees method?
A) payFees();
B) student.payFees();
C) Student.payFees();
A) payFees();
B) student.payFees();
C) Student.payFees();
B
3
The Array object's concat method returns a new array that is formed by concatenating the argument array to the end of the calling object array.
True
4
An object has properties and methods. It is the properties that provide the interface with the outside world.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
5
OOP stands for ____________________.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
6
If the following code executes, what message displays in the resulting dialog box?
var x = 3.5;
alert(x > 3 ? x + 1 : x - 1);
var x = 3.5;
alert(x > 3 ? x + 1 : x - 1);
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
7
Why might it be appropriate for a button's onclick event-handler function to call its event object's stopPropagation method?
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
8
Provide code that instantiates an array named carMakes such that the new array contains "Ford" and "Honda".
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
9
Sort the following three strings so they are in ascending lexicographical order (words that are considered less than other words should be at the left).
"aardvark", "African polecat", "AARP"
"aardvark", "African polecat", "AARP"
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
10
What is a two-dimensional array?
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
11
The formal term for creating an object is:
A) objectification.
B) creation.
C) instantiation.
A) objectification.
B) creation.
C) instantiation.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
12
What is the difference between a method heading and a function heading?
A) A method heading uses the word <code>method</code> at the left.
B) A function heading uses the word <code>function</code> at the left.
C) A method heading includes parameters and a function heading provides arguments.
D) A function heading includes parameters and a method heading provides arguments.
A) A method heading uses the word <code>method</code> at the left.
B) A function heading uses the word <code>function</code> at the left.
C) A method heading includes parameters and a function heading provides arguments.
D) A function heading includes parameters and a method heading provides arguments.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
13
If you declare a variable with <code>var</code>, but do not initialize it to a value, what will the variable contain?
A) <code>undefined</code>
B) <code>null</code>
C) 0
A) <code>undefined</code>
B) <code>null</code>
C) 0
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
14
Suppose an <code>onclick</code> event-handler function includes an <code>e</code> parameter for its passed-in event object. What code could be used to access the mouse pointer's x coordinate position?
A) <code>xValue</code>
B) <code>e.clientX</code>
C) <code>e.getXCoordinate();</code>
A) <code>xValue</code>
B) <code>e.clientX</code>
C) <code>e.getXCoordinate();</code>
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
15
Using the formal JavaScript inheritance terms, which of the following is true?
A) A subclass inherits from a superclass.
B) A superclass inherits from a subclass.
C) A generic class inherits from a specific class
A) A subclass inherits from a superclass.
B) A superclass inherits from a subclass.
C) A generic class inherits from a specific class
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
16
A class property is associated with a class as a whole, not with an individual instance of a class.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
17
To call a regular method, you preface the method name with an object and a dot. The object is referred to as a cotterized object.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
18
To emulate a class with legacy code, you implement a function whose name serves as a class name, and that function then serves as a constructor.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
19
Polymorphism refers to a variable's ability to change its type from a string to a number.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
20
A(n) __________ is a special method that gets called when there is an attempt to create an object.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
21
To sort an array of objects, you need to define a comparison function. The comparison function:
A) uses lexicographical ordering to perform the sort operation.
B) uses standard numerical ordering to perform the sort operation.
C) receives two elements from the array and returns a negative number, zero, or a positive number.
D) receives two elements from the array and returns true if the two elements should be swapped.
A) uses lexicographical ordering to perform the sort operation.
B) uses standard numerical ordering to perform the sort operation.
C) receives two elements from the array and returns a negative number, zero, or a positive number.
D) receives two elements from the array and returns true if the two elements should be swapped.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
22
If you would like to sort an array of date values, you should do which of the following?
A) Store the dates as strings because strings can be sorted more effectively than Date objects.
B) Store the dates as Date objects because Date objects can be sorted more effectively than strings.
C) Write an algorithm that parses date strings into their month, day, and year parts.
A) Store the dates as strings because strings can be sorted more effectively than Date objects.
B) Store the dates as Date objects because Date objects can be sorted more effectively than strings.
C) Write an algorithm that parses date strings into their month, day, and year parts.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
23
The switch statement is most similar to which of the following?
A) "if by itself" form of the if statement
B) "if, else if " form of the if statement
C) while loop
D) do loop
A) "if by itself" form of the if statement
B) "if, else if " form of the if statement
C) while loop
D) do loop
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
24
Suppose you have a subclass Truck, a superclass Vehicle, and a property in Vehicle named year. How can a method in Truck access the year property?
A) year
B) this.year
C) super.year
D) Vehicle.year
A) year
B) this.year
C) super.year
D) Vehicle.year
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
25
When a function is called by another function (as opposed to when a function is called by an event handler attribute like onclick), the called function is known as a helper function.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
26
Legacy code is code that has improved over time to the point where it is now considered an exemplar of what good code should look like.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
27
The ______ method searches for a specified value within the calling object array's elements. It returns the index of the first element that holds the value.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
28
For the switch statement, if you need to do something special when there are no case constants that match the controlling expression's value, then you should use the keyword ______ at the bottom of the switch statement to handle that situation.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
29
To implement a subclass, you need to append the keyword ______ and then the superclass name to the end of the subclass's heading.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
30
UML stands for Unified __________ Language.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck