CSCE Final Exam Study Set

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Which header file should be used while working with the output string stream?

#include <sstream>

How is the expression evaluated? ! x - 3 > 0

((!x) - 3) > 0

Which expression fails to compute the area of a triangle having base b and height h (area is one-half base time height)?

(1 / 2) * b * h

Which expression for XXX outputs "Modern era" for any year 1980 and later? if (year < 2000) { // Output "Past" } else if (XXX) { // Output "Modern era" }

(No such expression exists)

Both must be true for a person to ride: (1) At least 5 years old, (2) Taller than 36 inches. Which expression evaluates to true if a person can ride?

(age >= 5) && (height > 36)

The _______ member access operator is used to access a member using the this pointer.

->

Which of the following statements is true about the member access operator (->)?

The member access operator is always a non-static member function.

Which of the following is true for overloading a class constructor?

The parameter types of the constructors should be different.

Which is true regarding this preprocessor directive? #include <stdfile.h>

The preprocessor looks for stdfile in the system's standard library

Which of the following statements is not true for a recursive function?

The user has to free up stack space manually.

If the input is 7, what is the output? If x less than 10 Put "Tiny " to output Else Put "Not tiny " to output If x less than 100 Put "Small " to output

Tiny Small

Which of the following is an example of a recursive function?

Trimming the hedges: Turn on the hedge trimmer. Run the hedge trimmer along the top and again on the sides for a section. Trim along each section of the hedge.

Programmers commonly depict inheritance relationships using _____.

UML notations

_____ is a predefined ostream object that is pre-associated with a system's standard output, usually a computer screen.

cout

Choose the statement(s) that generate(s) this output: I wish you were here

cout << "I wish" << endl;cout << "you were here"

Which statement will generate 3.140e+00 as the output?

cout << setprecision(3) << scientific << 3.14;

Which is the best function stub for a function that calculates an item's tax?

double ComputeTax(double itemPrice) { cout << "FIXME: Calculate tax" << endl; return 0.0; }

A recursive function _____.

either calls itself or is in a potential cycle of function calls

Given x = 1, y = 2, and z = 3, how is the expression evaluated? In the choices, items in parentheses are evaluated first. <pre><code>(x == 5) || (y == 2) && (z == 5)</code></pre>

false OR (true AND false) --> false OR false --> false

Assuming char* firstSymbol; is already declared, return a pointer to the first instance of an '!' in userInput.

firstSymbol = strchr(userInput, '!');

Which is a valid definition for a function that passes two integers (a, b) as arguments, and returns an integer?

int MyFunction(int a, int b)

Which statement declares a two-dimensional integer array called myArray with 3 rows and 4 columns?

int myArray[3][4];

Manipulators are defined in the _____ and _____ libraries in namespace std.

iomanip; ios

Which of the following is not an exception-handling construct?

keep

To quit, a user types 'q'. To continue, a user types any other key. Which expression evaluates to true if a user should continue?

key != 'q'

Header file guards are preprocessor directives whose primary role is to cause the compiler to _____

only include the contents of the header file once

What line of code assigns a char variable outputGames with the value the gamesPointer points to? char userGames = 'B';char* gamesPointer;

outputGames = *gamesPointer;

The process of redefining the functionality of a built-in operator, such as +, -, and *, to operate on programmer-defined objects is called operator _____.

overloading

When a derived class defines a member function that has the same name, parameters, and return type as a base class's function, the member function is said to _____ the base class's function.

override

Declaring a member as ____ in the base class provides access to that member in the derived classes but not to anyone else.

protected

What line of code makes the character pointer studentPointer point to the character variable userStudent? char userStudent = 'S'; char* studentPointer;

studentPointer = &userStudent;

Assuming a class Student has been defined, which of the following statements is correct for declaring a vector?

vector<Student> studList;

Which declares two related integer vectors named personName and personAge each with 50 elements?

vector<int> personName(50); vector<int> personAge(50);

Which of the following declaration is an accessor?

void GetName() const;

Which statement is incrementing the integer x, where y is also an integer?

x = x + 1;

Which expression for YYY will result in an output of "Pass" only if x is exactly 32? if(YYY) { printf("Pass"); } else { printf("Fail"); }

x == 32

A program should compute two times x. Which statement has a logic error?

y = x * x;

Which of the following is the LinkedList class destructor?

~LinkedList();

Which of the following members of the class Movies will be called automatically when an object of the class is destroyed?

~Movies();

Which is a valid preprocessor directive?

#include "filename.h"

What is y after executing the statements? x = 4; y = x + 1; x = 3; y = y * 2;

10

What values for x cause Branch 1 to execute? If x > 100 : Branch 1 Else If x > 200: Branch 2

101 or larger

What is the ending value of x? int y = 6; x = (1 / 2) * y + 8;

11

What is y after executing the statements? x = 5; y = x + 1; y = y * 2;

12

What is the ending value of x? x = 160 / 20 / 4;

2

Which expression is evaluated first? w = y + 2 + 3 * x + z;

3 * x

The _____ operator is used to inherit one class from another.

:

A program can insert characters into an ostringstream buffer using the ______ operator.

<<

Which operator is the insertion operator?

<<

Given two integer vectors origList = {2, 3, 4, 5} and offsetList = {6, 7, 8, 9}, which statement prints out the sum of the second element in the origList with the corresponding element in the offsetList?

<code>cout << origList.at(1) + offsetList.at(1) << endl;</code>

Which if branch executes when an account lacks funds and has not been used recently? hasFunds and recentlyUsed are booleans and have their intuitive meanings.

<pre><code>if (!hasFunds && !recentlyUsed)</code></pre>

In which standard library of C++ is the runtime_error defined?

<stdexcept>

Which statement is true about inheritance?

A class can serve as a base class for multiple derived classes.

Which of the following statements is true about public member functions of a class?

A class user can call the functions to operate on the object.

Which is true regarding how functions work?

A function's local variables are discarded upon a function's return; each new call creates new local variables in memory

Which of the following statements is true about private data members of a class?

A member function can access the private data members, but class users cannot.

Which of the following statements is true about a memory leak?

A memory leak occurs when a program allocates memory but loses the ability to access the allocated memory.

Which of the following statements is true about a class' private helper function?

A private helper function helps public functions carry out tasks.

Which of the following items should undergo regression testing?

A tested class where three new functions have been added.

What does the compiler do upon reaching this variable declaration? int x;

Allocates a memory location for x

Which is true about accessors?

An accessor reads a class' data members

Which of these is a dynamically allocated array?

An array whose size can change during runtime.

Which of the following statements is true about inline member functions of a class?

An inline function is typically a short function definition with compact code.

Which is true regarding sizing of arrays and vectors?

Appending an element to a vector automatically resizes the vector if necessary

Which operator is overloaded to copy objects?

Assignment operator

Which syntax is used to create a template object of data type myData for a class className?

className<myData> classObject;

Two vectors, itemsNames and itemsPrices, are used to store a list of item names and their corresponding prices. Which is true?

Both vectors should be declared to have the same number of elements.

Which of the following relationships depicts an is-a relationship?

Building - School

Which of the following is true for concrete classes?

Concrete classes do not have any pure virtual functions.

Given a function with one vector parameter ages. How should the parameter be defined if ages may be very large, and the function will not modify the parameter?

Constant, and pass by reference

For the given outline, identify the correct statement for defining classes for a program that stores electronic items' details. The program will have an Electronic class with item code, item description, and item price. An item may be a gaming item with console details and brand.

Create an Electronic class as separate files and then a Gaming class which includes the Electronic.h file.

Which of the following statements is true about destructors?

Destructors are used to deallocate the memory that has been allocated for the object.

For what values of integer x will Branch 3 execute? If x < 10 : Branch 1<br/> Else If x > 9: Branch 2 Else: Branch 3

For no values (never executes)

Which of the following cannot be included in a stack frame?

Global variables

Which is true regarding header files?

Header files serve as a brief summary of all functions available

For which quantity is a double the best type?

Height of a building

Which of the following statements describes an abstraction?

Hiding the implementation and the important features

The codes for class Hotel has been defined in two separate files Hotel.h, and Hotel.cpp. Which of the following statements is true?

Hotel.cpp contains member function definitions and includes Hotel.h.

What is unit testing?

Individually testing a small part (or unit) of a program, typically a function, using a separate program called a test harness

For an enumerated type like below, the compiler assigns what kind of value to RED, GREEN, and BLACK. enum CarColor {RED, GREEN, BLACK};

Integer

Which of the following statements is true for a static data member?

It is a data member of each class object.

A programmer is overloading the equality operator (==) and has created a function named operator==. Which of the following statements are true about this function?

It returns bool and takes two const reference arguments of the class type.

Which of the following statements is not true for stack overflow?

Large vectors, arrays, or strings declared as local variables, or passed by copy, cannot lead to stack overflow.

Which is the correct syntax for the class's functions defined outside the class declaration?

Larger<varType> :: largeFunc();

Given a function with one vector parameter scores. How should the parameter be defined if scores may be very large, and the function will modify the parameter?

Not constant, and pass by reference

Programmers often use a powerful programming paradigm that consists of three key features — classes, inheritance, and abstract classes. What is the paradigm called?

Object-oriented programming

Which statement declares a copy assignment operator for a class named PatientDetails using inVal as the input parameter name?

PatientDetails& operator = (const PatientDetails& inVal);

Which is not a special member function of a class?

Pointer

_____ refers to determining which program behaviour to execute depending on data types.

Polymorphism

Which statement defines the character search function strrchr()?

Returns a pointer to the last occurrence of the character.

Consider that there is a class Team for soccer team members under Soccer namespace and another class Team for basket team members under the Basketball namespace. What is the correct syntax that will help the compiler identify the correct Team?

Soccer::Team SoccerTeamMembers; Basketball::Team BasketballTeamMembers;

Which statement is not true?

Strings passed as const char* can be modified by the function.

Which is true about testing a function with three integer parameters and one integer return value?

Using various calls involving assert() is a good way to test the function

A programmer must write a 500 line program. Which is most likely the best approach?

Write 10-20 lines, run and debug, write 10-20 more lines, run and debug, repeat

Which of the following statements allocates memory in the heap?

a = new int;

A linked list's head node stores _____ in the list.

a pointer to the first item node

The new operator _____.

a. returns a pointer to the allocated memory

Which shows valid accesses for an array a and vector v, each with 10 elements?

a[5] v.at(5)

The function terminate() is used to _____.

abort the program

UML uses italics to denote ___ classes.

abstract

A ___ encapsulates data and behavior to create objects.

class

A(n) _____ can be used to implement an abstract data type (ADT).

class

The _____ construct defines a new type to group data and functions to form an object.

class

Which of the following exception-handling constructs is known as handler?

catch

In a linked list, a node is comprised of a(n) _____.

data element and a pointer to the next node

Which destructor can be used to avoid a memory leak?

delete

Which statement properly frees the dynamically allocated array below? Musketeer* musketeers = new Musketeer[8];

delete [] musketeers;

The automatic process of finding and freeing unreachable allocated memory locations is called a _____.

garbage collection

The _____ function reads an input line into a string.

getline();

Which reads an entire line of text into string myString?

getline(cin, myString);

When an exception is thrown within a function and it is not caught within that function, the function is immediately exited and the calling function is checked for a _____.

handler

Default parameters may appear _____

in the parameters of a function definition

Which keyword is used to declare a header file?

include

When a class derives the properties of the base class, the concept is called _____.

inheritance

myString is declared as a string and is the only variable declared. Which is a valid assignment?

myString = "H";

Which assigns the array's first element with 99? int myVector[4];

myVector[0] = 99;

Identify the statement that makes a shallow copy of the object origObj to the new object newObj by creating a copy of the data members' values only.

newObj.member2 = origObj.member2;

*What is the return type for constructors?

none

A soccer coach scouting players has to enter the jersey number of players and print a list of those numbers when required. Identify the function that can help with this.

push_back()

Given array scorePerQuiz has 10 elements. Which assigns element 7 with the value 8?

scorePerQuiz[7] = 8;

An identifier can _____

start with an underscore

The ostringstream member function ____ returns the contents of an ostringstream buffer as a string.

str()

A _____ diagram visualizes static elements of a program, such as the variables and functions.

structural

If a program compiles without errors, the program is free from _____.

syntax errors

Which function by default aborts the program when the exception handling mechanism cannot find a handler for a thrown exception?

terminate()

A _____ is a program used to thoroughly test another program (or portion of a program) through a series of input/output checks.

testbench

If a function definition has three parameters, one of which the programmer gives a default value, then _____.

that parameter must be the last parameter

Heap is a region in program memory where _____.

the "new" operator allocates memory

If a programmer doesn't define a copy assignment operator to copy objects, _____.

the compiler implicitly defines one that does a memberwise copy

A commuter swipes a public transport card at a kiosk and sees his account balance displayed on the screen. The commuter would be viewing an abstraction if _____.

there is other information about his account that is not displayed onscreen

Which is an syntax of exception handling?

try("invalid input");

Which assigns the last array element with 20? int userNum[N_SIZE];

userNum[N_SIZE - 1] = 20;

A pointer is a(n) _____ that contains a _____.

variable, memory address


Set pelajaran terkait

Med Surg Ch. 42 Musculoskeletal Trauma

View Set

School Choice - POLI 478 Exam Review

View Set

PHYSIOLOGICAL PSYCH. EXAM 2 (CH 5-CH 8)

View Set

Ch 28 Obstructive Pulmonary Disease

View Set

English File Intermediate. Unit 5A. Vocabulary & Speaking pg. 157 (Sports)

View Set

Marketing 301 Exam 2 Review Part 1

View Set

Chapter 5: separate and together: life in groups

View Set