Deck 2: C++ Function and Array
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/25
Play
Full screen (f)
Deck 2: C++ Function and Array
1
When arguments are passed by value, the function works with the original arguments in the calling program.
False
2
Which of the following can legitimately be passed to a function?
A)a constant
B)a variable
C)a structure
D)all of the above
A)a constant
B)a variable
C)a structure
D)all of the above
all of the above
3
How many values can be returned from a function?
A)0
B)1
C)2
D)3
A)0
B)1
C)2
D)3
1
4
When a function returns a value, the entire function call can appear on the right side of the equal sign and be assigned to another variable.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
5
When an argument is passed by reference
A)a variable is created in the function to hold the argument's value.
B)the function cannot access the argument's value.
C)a temporary variable is created in the calling program to hold the argument's value.
D)the function accesses the argument's original value in the calling program.
A)a variable is created in the function to hold the argument's value.
B)the function cannot access the argument's value.
C)a temporary variable is created in the calling program to hold the argument's value.
D)the function accesses the argument's original value in the calling program.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
6
Overloaded functions
A)are a group of functions with the same name.
B)all have the same number and types of arguments.
C)make life simpler for programmers.
D)a and c
A)are a group of functions with the same name.
B)all have the same number and types of arguments.
C)make life simpler for programmers.
D)a and c
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
7
A static local variable is used to
A)make a variable visible to several functions.
B)make a variable visible to only one function.
C)retain a value when a function is not executing.
D)b and c
A)make a variable visible to several functions.
B)make a variable visible to only one function.
C)retain a value when a function is not executing.
D)b and c
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
8
In C++ there can be an array of four dimensions.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
9
When an array name is passed to a function, the function
A)accesses exactly the same array as the calling program.
B)refers to the array using a different name than that used by the calling program.
C)refers to the array using the same name as that used by the calling program.
D)a and b
A)accesses exactly the same array as the calling program.
B)refers to the array using a different name than that used by the calling program.
C)refers to the array using the same name as that used by the calling program.
D)a and b
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
10
The compiler will complain if you try to access array element 14 in a 10-element array.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
11
The extraction operator (>>) stops reading a string when it encounters a space.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
12
You can read input that consists of multiple lines of text using
A)the normal cout <<combination.
B)the cin.get() function with one argument.
C)the cin.get() function with two arguments.
D)the cin.get() function with three arguments.
A)the normal cout <<combination.
B)the cin.get() function with one argument.
C)the cin.get() function with two arguments.
D)the cin.get() function with three arguments.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
13
You should prefer C-strings to the Standard C++ string class in new programs.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
14
Objects of the string class
A)are zero-terminated.
B)can be copied with the assignment operator.
C)do not require memory management.
D)both b and c
A)are zero-terminated.
B)can be copied with the assignment operator.
C)do not require memory management.
D)both b and c
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
15
Can destuctors be private in C++?
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
16
What is value of size?
A)28
B)32
C)20
D)24
A)28
B)32
C)20
D)24
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
17
What value will be printed for data.i?
A)10 220.5 230.5 unpredictable value
B)220
C)230.5
D)unpredictable value
A)10 220.5 230.5 unpredictable value
B)220
C)230.5
D)unpredictable value
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
18
What is the compilation error for this program?
A)each undeclared identifier is reported only once
B)cout and cin not declared in scope
C)invalid conversion from int to float
D)all of the above
A)each undeclared identifier is reported only once
B)cout and cin not declared in scope
C)invalid conversion from int to float
D)all of the above
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
19
What will be the output of the program?
A)1
B)default value
C)will not compile
D)none of the above
A)1
B)default value
C)will not compile
D)none of the above
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
20
What is the output of the program?
A)0 0
B)x = 0 y = 0
C)0
D)compilation error
A)0 0
B)x = 0 y = 0
C)0
D)compilation error
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
21
Which function will change the state of the object?
A)only set()
B)only display()
C)display() and set() both
D)none of the above
A)only set()
B)only display()
C)display() and set() both
D)none of the above
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
22
What will be the output of the following program?
A)compilation error: display() cannot be accessed in application
B)compilation error:test class object cannot be accessed in function demo
C)compilation error: variable x is private in test
D)both a and b
A)compilation error: display() cannot be accessed in application
B)compilation error:test class object cannot be accessed in function demo
C)compilation error: variable x is private in test
D)both a and b
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
23
The only integer that can be assigned directly to a pointer is
A)0
B)-1
C)999
D)-999
A)0
B)-1
C)999
D)-999
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
24
Which of the following feature is not supported by C++?
A)exception handling
B)reflection
C)operator overloading
D)namespace
A)exception handling
B)reflection
C)operator overloading
D)namespace
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
25
The operators that cannot be overloaded is
A)*
B)-
C)::
D)()
A)*
B)-
C)::
D)()
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck