Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

ECET 299 C++ & OOP QUESTIONS & ANSWERS 2022 LATEST UPDATE

Rating
-
Sold
-
Pages
32
Grade
A+
Uploaded on
25-03-2022
Written in
2021/2022

ECET 299 C++ & OOP QUESTIONS & ANSWERS 2022 LATEST UPDATE MC (TCO 4) What is the result of 5 % 7? (7 points) Week 12, Final Attempt 3(Current Exam) 0 2 5 7 Instructor Explanation:Malik, pages 39–40 MC(TCO 4) A variable declared before and outside all function blocks(7 points) Week 12, Final Attempt 3(Current Exam) is visible only in main. is visible to all functions. is visible to all functions except main. is not visible to any functions. Instructor Explanation:Malik, pages 50–65 MC(TCO 4) What is the value of data after the following code executes? unsigned char data = 0xA5; data = data & 0xF0;(7 points) Week 12, Final Attempt 3(Current Exam) 0xA0 0xF0 0xF5 0x5A Instructor Explanation:Malik, pages 32–42 MC(TCO 4) What is the bit pattern in data after the following statements execute? unsigned int data = 10; data = data | 0x0B; data = data 1;(7 points) Week 12, Final Attempt 3(Current Exam) 0x314 0x154 0x342 0x156 Instructor Explanation:Malik, pages 32–42 MC(TCO 4) Why does this code snipper give a compile error? int loopCounter = 0; int numberOfScores = 20; while (loopcounter numberOfScores) cout “nInside the loop”;(7 points) Week 12, Final Attempt 3(Current Exam) The value of the control loop control variable does not change the loop body. The curly brackets are missing around the loop body. The loopCounter variable is not spelled consistently. All of the above Instructor Explanation:Malik, pages 32–42 MC(TCO 4) Which of the following is not a C++ logical operator?(7 points) Week 12, Final Attempt 3(Current Exam) # && ││ ! Instructor Explanation:Malik, pages 57–67 MC(TCO 4) What is the value of i after the following code fragment executes? int i = 2; int k = 5 ; i *= k + 1;(7 points) Week 12, Final Attempt 3(Current Exam) 7 11 12 14 Instructor Explanation:Malik, pages 57–67 MC(TCO 4) Which looping statement is best if the number of iterations is known?(7 points) Week 12, Final Attempt 3(Current Exam) If/Else For While Do/While Instructor Explanation:Malik, pages 57–67 MC(TCO 4) Which operation in the following expression will be performed first? c = a++ / b + 5;(7 points) Week 12, Final Attempt 3(Current Exam) a a/b assignment to c b + 5 Instructor Explanation:Malik, pages 57–67 MC(TCO 4) What is the value stored in variable c, after the execution of the following statement? int a=5, b=2, c; c = ++a / b + 5;(7 points) Week 12, Final Attempt 3(Current Exam) 7.5 8 7 0 Instructor Explanation:Malik, pages 57–67 MC (TCO 4) What is the value stored in variable c, after the execution of the following statement? int a=5, b=2, c; c = a++ / b + 5;(7 points) Week 12, Final Attempt 3(Current Exam) 7.5 8 7 0 Instructor Explanation:Malik, pages 57–67 MC(TCO 4) If firstName and lastName are string object variables, which statement can be used to combine (append or concatenate) the two into a single string variable?(7 points) Week 12, Final Attempt 3(Current Exam) fullName = firstName + lastName; fullName = firstName, lastName; fullName = firstName & lastName; fullName = firstName && lastName; Instructor Explanation:Malik, pages 182–191 MC(TCO 4) Which of the following expressions is correct if you want to end a while-loop when the character variable keepgoing is anything other than character y in either upper or lowercase?(7 points) Week 12, Final Attempt 3(Current Exam) while (keepgoing == “y” ││ keepgoing == “Y”) while (keepgoing == ‘y’ && keepgoing == ‘Y’) while (keepgoing == “y” ││ keepgoing == “Y”) while (keepgoing == ‘y’ ││ keepgoing == ‘Y’) Instructor Explanation:Malik, pages 249–260 MC(TCO 4) C++ selection statements include (7 points) Week 12, Final Attempt 3(Current Exam) for, while, do-while. cout and cin. if, if-else, if-else if, switch. #include iostream and using namespace std;. Instructor Explanation:Malik, pages 249–260 MC(TCO 4) What is wrong with the following switch statement? switch(x) { case 0: cout x; case 2: cout 2 / x; break; Week 12, Final Attempt 3(Current Exam) default: cout “error”; break; }(7 points) The value of x could be something other than 1 or 2. There is no break statement for case 1. There is no semicolon after the closing bracket. All of the above Instructor Explanation:Malik, pages 273–284 MC(TCO 4) What is the final number output for the following code snippet? for (i = 1 ; i = 20 ; i = i + 2); cout “ “ i ;(7 points) Week 12, Final Attempt 3(Current Exam) 10 19 20 This is an illegal set-up of for loop parameters. Instructor Explanation:Malik, pages 273–284 MC(TCO 4) How many times will variable i be printed to the screen? for (i = 1 ; i = 20 ; i = i + 2); { cout “ “ i ; }(7 points) Week 12, Final Attempt 3(Current Exam) 10 20 1 0 Instructor Explanation:Malik, pages 273–284 MC(TCO 4) What output does the following code produce? cout fixed setprecision(3); double pi = 3.14159; cout pi endl;(7 points) Week 12, Final Attempt 3(Current Exam) 3.14159 3.142 3.14 None of the above Instructor Explanation:Malik, pages 300–301 MC(TCO 4) What is the declaration for a C-style string that can hold a name with up to 3 printable characters (for example, “Ron”)?(7 points) Week 12, Final Attempt 3(Current Exam) int name [3]; char name [3] int name [4]; char name [4]; Instructor Explanation:Malik, pages 487–494 MC(TCO 4) The code below computes the length of a C-style string. What should the value of FLAG be? char name[20]= "Lancilot"; int length=0; while(name[length] != FLAG) { length = length+1; } cout length endl;(7 points) Week 12, Final Attempt 3(Current Exam) ‘0’ 20 NULL 0 Instructor Explanation:Malik, pages 487–494 MC (TCO 4) The code below declares and initializes an array of integers. What can we say about the values stored in grades[2], grades[3], grades[4]? int grades[5] = {95, 96}; (7 points) Week 12, Final Attempt 3(Current Exam) They are initialized to 96, 96, 96. We cannot tell. They are initialized to 97, 98, 99. They are initialized to 0, 0, 0,. Instructor Explanation:Malik, pages 487–494 MC(TCO 4) Given the following code to fill an array, int; int data[100]; for(int i = 0; i = X; i++) data[i] = i; what should the value of X be?(7 points) Week 12, Final Attempt 3(Current Exam) 100 101 99 i Instructor Explanation:Malik, pages 487–494 MC(TCO 4) How many elements does the following array contain? double data [100] [500];(7 points) Week 12, Final Attempt 3(Current Exam) 500 100 600 50,000 Instructor Explanation:Malik, pages 518–524 MC(TCO 4) Given the following code fragment, what is the data type of thisStudent? struct student { string name; double gpa; }; student thisStudent;(7 points) Week 12, Final Attempt 3(Current Exam) string const pointer to student student double Instructor Explanation:Malik, pages 518–524 MC(TCO 4) Given the code below, struct student { string name; double gpa; }; which statement declares an array of 10 students, called Week 12, Final Attempt 3(Current Exam) myClass?(7 points) const int N=10; struct student x[N]; const int N=10; struct myClass students[N]; int N=10; struct student myClass[N]; const int N=10; struct student myClass[N]; Instructor Explanation:Malik, pages 518–524 MC(TCO 4) Which statement correctly declares an array of 10 LunchBoxes. The LunchBox data type is already defined and is a struct that contains a ‘snack’ field, and a ‘drink’ field.(7 points) Week 12, Final Attempt 3(Current Exam) snack snacks[10]; drink drinks[10]; LunchBox snacks[10]; x LunchBox[10] snacks LunchBox[10]; Instructor Explanation:Malik, pages 518–524 MC(TCO 4) Given the following code fragment, what is the data type of roster[9] .name? struct student { string name; double gpa; }; student thisStudent; student roster[50];(7 points) Week 12, Final Attempt 3(Current Exam) string const pointer to student student double Instructor Explanation:Malik, pages 518–524 MC(TCO 4) The following code fragment struct student { string name; double gpa; }; student thisStudent; cout “Enter this student’s name: “ flush; cin thisS; cout “Enter this student’s GPA: “ flush; cin thisS; student nextStudent = thisStudent;(7 points) Week 12, Final Attempt 3(Current Exam) copies both thisStudent’s name and gpa to nextStudent. displays the name and gpa of thisStudent. causes a compiler error. causes a run-time error. Instructor Explanation:Malik, pages 518–524 MC(TCO 4) Which type of error does the following code fragment cause? const int MAX = 500; int main (void) { int foo [MAX]; for (int i = 0; i = MAX; i++) { foo [i] = i * 2; }(7 points) Week 12, Final Attempt 3(Current Exam) Compiler, because of out-of-bounds array subscript Run-time, because of out-of-bounds array subscript Compiler, because of invalid array initialization None of the above. It does not create any type of error. Instructor Explanation:Malik, pages 518–524 MC(TCO 4) Which type of error does the following code fragment cause? Week 12, Final Attempt 3(Current Exam) int main (void) { int MAX; cout “Enter array size: “ flush; cin MAX; int foo [MAX]; for (int i = 0; i = MAX; i++) { foo [i] = i * 2; }(7 points) Compiler: Array size must be known at compile time. Compiler: Variable MAX cannot be all uppercase. Compiler: Array subscript out of bounds. Run-time: User cannot enter a value for MAX. Instructor Explanation:Malik, pages 612–619 MC (TCO 4) What is the data type of bullpen[3].era? struct pitcher { string name; double era; }; pitcher p1; pitcher bullpen[10];(7 points) Week 12, Final Attempt 3(Current Exam) string double pitcher const pointer to pitcher Instructor Explanation:Malik, pages 612–619 MC(TCO 4) Which of the following is an invalid declaration to overload the following function? double foo(int);(7 points) Week 12, Final Attempt 3(Current Exam) double foo(double); int foo(int); double foo(double *): double foo(int *); Instructor Explanation:Malik, pages 395–396 MC(TCO 4) If the function square(x) returns the square of x, then x should be passed by(7 points) Week 12, Final Attempt 3(Current Exam) value so it is protected (cannot be changed). reference so it is protected (cannot be changed). pointer so it is protected (cannot be changed). None of the above. X cannot be protected; square can change the value of x regardless of how it is passed. Instructor Explanation:Malik, pages 324–331 MC(TCO 4) What is the output of the following code? void func(int x) { x = x * 2; } int main( ) { int x = 10; func(x); cout x endl; }(7 points) Week 12, Final Attempt 3(Current Exam) 20 30 10 5 Instructor Explanation:Malik, pages 324–331 MC(TCO 4) What is the output of the following code? void func(int *x) { *x = *x * 3; }; int main() { int x = 10; func (&x) ; cout x endl ; }(7 points) Week 12, Final Attempt 3(Current Exam) 20 30 10 5 Instructor Explanation:Malik, pages 324–331 MC(TCO 4) What is the output of the following code? void func(int x[ ]) { x[0] = x[0] * 3; x[1[ = x[1] * 3; x[2] = x[2] * 3; } void main () { int x[ ] = {1, 2, 3}; func(x); cout x[0] “ “ x[1] “ “ x[2] endl; }(7 points) Week 12, Final Attempt 3(Current Exam) 1 2 3 3 4 5 3 6 9 3 3 3 Instructor Explanation:Malik, pages 367–386 MC(TCO 4) The function call below is designed to return, in variable result, the product of x and y. All the variables are of type int. What is the correct prototype for such a function? myFunction(&result, &x, &y);(7 points) Week 12, Final Attempt 3(Current Exam) void myFunction(int, int, int) ; void myFunction(int *, int *, int *) ; void myFunction(const int *, const int *, const int *) ; void myFunction(int *, const int *, const int *) ; Instructor Explanation:Malik, pages 367–386 MC(TCO 4) The function call below is designed to return, in variable result, the product of x and y. All the variables are of type int. What is the correct prototype for such a function? myFunction(result, x, y);(7 points) Week 12, Final Attempt 3(Current Exam) void myFunction(int &, int, int) ; void myFunction(int, int, int) ; void myFunction(const int *, const int, const int) ; void myFunction(int *, const int *, const int *) ; Instructor Explanation:Malik, pages 367–386 MC(TCO 4) Which of the following function definitions uses pass-by-values?(7 points) Week 12, Final Attempt 3(Current Exam) int myFunc( int * x, int * y ); int myFunc( int x, int y ) ; int myFunc( int & x, int & y ) ; int myFunc( int @ value1, int @ value2 ) ; Instructor Explanation:Malik, pages 367–386 MC(TCO 4) Which of the following functions is taking an array of MyStruct structures as a pass by value parameter?(7 points) Week 12, Final Attempt 3(Current Exam) void MyFunc( MyStruct data[ ] ); void MyFunc( MyStruct &data[ ] ); void MyFunc( MyStruct *data[ ] ) ; Not allowed in C++ Instructor Explanation:Malik, pages 367–386 (TCO 4) Identify the correct prototype for a function that receives an array of doubles, computes the sum of all the elements of the array, and returns the sum to the calling function.(7 points) Week 12, Final Attempt 3(Current Exam) void computeSum(double array[], int size, double * sum); void computeSum(double array[], int size, double & sum); double computeSum(double array[], int size); All of the above Instructor Explanation:Malik, pages 367–386 MC (TCO 4) Identify the correct prototype for a function that receives an array of doubles, finds the position of the largest value in the array, and returns the position to the calling function.(7 points) Week 12, Final Attempt 3(Current Exam) void findPosition(double array[], int size, double * position); void findPosition (double array[], int size, int * position); double findPosition (double array[], int size); All of the above Instructor Explanation:Malik, pages 367–386 MC (TCO 4) Which of the following statements call the following function correctly? int MultiplyValues (int, int);(7 points) Week 12, Final Attempt 3(Current Exam) int a = MultiplyValues (int x, int y); int a = MultiplyValues (10, 20); double d = MultiplyValues (int 10, int 20); All of the above Instructor Explanation:Malik, pages 367–386 MC (TCO 4) When a variable is passed by reference (7 points) Week 12, Final Attempt 3(Current Exam) the variable can be changed by the calling and the called function. the parameter name is an alias of the variable passed. the called function can change the value of the variable in the calling program. All of the above Instructor Explanation:Malik, pages 367–386 MC (TCO 4) Which of the following is a valid declaration to overload the following function? Week 12, Final Attempt 3(Current Exam) int whatever (double x);(7 points) double whatever (double x); int whatever (int x); int whatever2 (double x); int overload (double x); Instructor Explanation:Malik, pages 650–655 MC (TCO 4) When organizing a program into three files (main, class implementation, and class header), which is not a .cpp file?(7 points) Week 12, Final Attempt 3(Current Exam) Main None are .cpp Class header Class implementation Instructor Explanation:Malik, pages 650–655 MC (TCO 4) When organizing a program into three files (main, class implementation, and class header), where are user-defined data types declared?(7 points) Week 12, Final Attempt 3(Current Exam) class.h main.h Instructor Explanation:Malik, pages 650–655 MC (TCO 4) Creating classes with private data members is an example of(7 points) Week 12, Final Attempt 3(Current Exam) encapsulation. polymorphism. inheritance. abstraction. Instructor Explanation:Malik, pages 650–655 MC (TCO 4) Creating one class from another in a parent/child hierarchy is an example of(7 points) Week 12, Final Attempt 3(Current Exam) encapsulation. polymorphism. inheritance. abstraction. Instructor Explanation:Malik, pages 650–655 MC (TCO 4) What is the name of a member function of a class that only accesses the value(s) of member variable(s) and does not modify the value(s)?(7 points) Week 12, Final Attempt 3(Current Exam) Set Private Member Accessor Instructor Explanation:Malik, pages 650–655 MC (TCO 4) A derived class is typically an example Week 12, Final Attempt 3(Current Exam) of(7 points) a “has a” relationship. an “is a” relationship. a “uses a” relationship. a “is used” relationship. Instructor Explanation:Malik, pages 664–677 MC(TCO 4) Composition is typically an example of(7 points) Week 12, Final Attempt 3(Current Exam) a “has a” relationship. an “is a” relationship. a “uses a” relationship. a “is used” relationship. Instructor Explanation:Malik, pages 664–677 MC(TCO 4) The word const inside the parentheses of the following declaration of isEqual bool isEqual (const Distance & rightSideObject) const;(7 points) Week 12, Final Attempt 3(Current Exam) ensures the member variables of the called objects are protected (cannot be changed). ensures the argument passed in to the function is protected (cannot be changed). ensures the return value of the function is protected (cannot be changed). ensures the return value is routed to the proper variable. Instructor Explanation:Malik, pages 664–677 MC(TCO 4) Variables defined to be of a user-declared class are referred to as(7 points) Week 12, Final Attempt 3(Current Exam) attributes. member variables. primitive variables. objects. Instructor Explanation:Malik, pages 677–685 MC(TCO 4) Which of the following is called automatically each time an object is created?(7 points) Week 12, Final Attempt 3(Current Exam) Compiler Builder Constructor Destructor Instructor Explanation:Malik, pages 677–685 MC(TCO 4) Which of the following is called automatically each time an object goes out of scope?(7 points) Week 12, Final Attempt 3(Current Exam) Compiler Builder Constructor Destructor Instructor Explanation:Malik, pages 677–685 MC(TCO 4) How many parameters are required to overload the preincrement operator for a class as a member function?(7 points) Week 12, Final Attempt 3(Current Exam) None 1 2 No limit Instructor Explanation:Malik, pages 677–685 MC(TCO 4) Assume you have a class, called Simple, that has two data members, ‘a’ and ‘b’, both of type int. What can be said about the function prototype given below? (Choose the best answer.) Simple(int=0, int=0);(7 points) Week 12, Final Attempt 3(Current Exam) It is the prototype for the default constructor. It is the prototype for the 2-argument constructor. It is both the 0-argument, and the 2-argument, constructor. It is incorrect. Instructor Explanation:Malik, pages 677–685 MC(TCO 4) Given the following class definition and lines of code, what, if anything, is wrong with Line 6 in main? class Distance { private: int feet; double inches; public: Distance( ); Distance(int initFt, double initIn); void setFeet(int feetIn); void setInches(double inchesIn); int getFeet() const; double getInches( ) const; }; int main( ) { Distance d1; //Line 1 const int MAX = 100; //Line 2 Distance list [MAX]; //Line 3 Distance d2(1, 2.3); //Line 4 Distance * pDist; //Line 5 = 5; //Line 6 // etc. – assume the remaining code is correct }(7 points) Week 12, Final Attempt 3(Current Exam) It will not compile: feet is private and cannot be directly accessed. Distance d1; should be changed to int d1;. The :: = 5; should be changed to d1(feet) = 5;. It will compile, but causes a run-time error because has not been declared. Instructor Explanation:Malik, pages 677–685 MC(TCO 4) A Distance class has two private members, ‘feet’, of type int, and ‘inches’, of type double. Which prototype correctly declares a 2-argument constructor for such class?(7 points) Week 12, Final Attempt 3(Current Exam) Distance(int, double); void Distance(int, double); int Distance(int, double); Distance(feet, inches); Instructor Explanation:Malik, pages 677–685 MC (TCO 4) Given the following class definition and lines of code, what would be displayed if Line 6 were replaced by the following? cout Feet() endl; class Distance { private: int feet; double inches; public: Distance( ); Distance(int initFt, double initIn); void setFeet(int feetIn); void setInches(double inchesIn); int getFeet() const; double getInches( ) const; }; int main( ) { Distance d1; //Line 1 const int MAX = 100; //Line 2 Distance list[MAX]; //Line 3 Distance d2(1, 2.3); //Line 4 Distance * pDist; //Line 5 = 5; //Line 6 // etc. – assume the remaining code is correct }(7 points) Week 12, Final Attempt 3(Current Exam) 0 1 2.3 5 Instructor Explanation:Malik, pages 724–734 MC(TCO 4) Given the following class definition and lines of code, Line 1 in main is a call to what? class Distance { private: int feet; double inches; public: Distance( ); Distance(int initFt, double initIn); void setFeet(int feetIn); void setInches(double inchesIn); int getFeet() const; double getInches( ) const; }; int main( ) { Distance d1; //Line 1 const int MAX = 100; //Line 2 Distance list[MAX]; //Line 3 Distance d2(1, 2.3); //Line 4 Distance * pDist; //Line 5 = 5; //Line 6 Week 12, Final Attempt 3(Current Exam) // etc. – assume the remaining code is correct }(7 points) The 0-argument Distance constructor The 2-argument, int, double, Distance constructor The 2-argument, double, int, Distance constructor The 1-argument, int, Distance constructor Instructor Explanation:Malik, pages 677–685 MC(TCO 4) A Distance class has two private members, ‘feet’, of type int, and ‘inches’, of type double. Which prototype correctly declares the copy constructor for such class?(7 points) Week 12, Final Attempt 3(Current Exam) Distance Distance(const Distance &); Distance(const Distance &); int Distance(int, double); Distance(feet, inches); Instructor Explanation:Malik, pages 677–685 MC(TCO 4) Which of the following is not a legal value to initialize a pointer variable?(7 points) Week 12, Final Attempt 3(Current Exam) Zero Null 0 The address of a variable of the same type Instructor Explanation:Malik, pages 796–809 MC(TCO 4) What is the data type of pDist for the code snippet below? Distance * pDIST;(7 points) Week 12, Final Attempt 3(Current Exam) Distance Const pointer to Distance Pointer to Distance None of the above Instructor Explanation:Malik, pages 796–809 MC(TCO 4) What is the output of the following code snippet? int *list = new int[5]; int *ptr; for (int i = 0; i 5; i ++) list [ i] = i+ 1; ptr = list; delete [ ] list; cout *ptr;(7 points) Week 12, Final Attempt 3(Current Exam) 1 Address of list Address of ptr Error – ptr references memory that no longer belongs to the program Instructor Explanation:Malik, pages 796–809 MC(TCO 4) Given the definition of some class called Employee, which of the following correctly dynamically allocates an array of 20 Employee objects?(7 points) Week 12, Final Attempt 3(Current Exam) Employee * myData = new Employee[20]; Employee myData[20] = new Employee[20]; Employee = myData[20]; Employee array = new Employee[20]; Instructor Explanation:Malik, pages 796–809 MC(TCO 4) Given the following definitions and statements, void myFunction (double * dptr);; double data [10]; which of the following statements correctly calls the function passing in the address of the data array?(7 points) Week 12, Final Attempt 3(Current Exam) myFunction(data); myFunction(&data); myFunction(*data); myFunction(data[0]); Instructor Explanation:Malik, pages 796–809 MC(TCO 4) Assume you have to write a class that makes use of dynamic memory allocation (the class needs to allocate and deallocate memory). According to best practices, where would the keyword ‘new’ be placed?(7 points) Week 12, Final Attempt 3(Current Exam) Classes are smart data types. The compiler takes care of calling new/delete. In the constructor In the destructor In a separate, dedicated function Instructor Explanation:Malik, pages 796–809 MC(TCO 4) Assume you have to write a class that makes use of dynamic memory allocation (the class needs to allocate and deallocate memory). According to best practices, where would the keyword ‘delete’ be placed?(7 points) Week 12, Final Attempt 3(Current Exam) Classes are smart data types. The compiler takes care of calling new/delete It is in the constructor. It is in the destructor. It is in a separate, dedicated function. Instructor Explanation:Malik, pages 796–809 MC (TCO 4) When writing a class, the compiler automatically creates some support functions for the class. What are some of these functions?(7 points) Week 12, Final Attempt 3(Current Exam) Assignment operator function Copy constructor Assignment operator and copy constructor None of the above Instructor Explanation:Malik, pages 796–809 MC (TCO 4) What is the default behavior for the overloaded operator and the copy constructor functions?(7 points) Week 12, Final Attempt 3(Current Exam) There is no default behavior. The user has to write both functions. It is shallow copy. It is deep copy. Both functions are empty stubs. Instructor Explanation:Malik, pages 796–809 MC (TCO 4) Assume you have to write a class that makes use of dynamic memory allocation (the class needs to allocate and deallocate memory). According to best practices, which function should you overwrite for proper Week 12, Final Attempt 3(Current Exam) memory management?(7 points) Assignment operator function Copy constructor Assignment operator and copy constructor None of the above Instructor Explanation:Malik, pages 796–809 MC (TCO 4) Given a class called Employee and the following definitions and statements, void myFunction (Employee * eptr); Employee emp; which of the following statements correctly calls the function passing in the address of the data array? (7 points) Week 12, Final Attempt 3(Current Exam) myFunction(emp); myFunction(&emp); myFunction(*emp); myFunction(**emp); Instructor Explanation:Malik, pages 796–809 MC (TCO 4) Given the following definitions, select the statement that is illegal? int * iptr; double * dptr; int j = 10; double d = 10.0;(7 points) Week 12, Final Attempt 3(Current Exam) iptr = &j; dptr = &d; iptr = 0; dptr = &j; Instructor Explanation:Malik, pages 796–809 MC (TCO 4) What is the output of the following code snippet? int value = 10; int * iptr = &value; *iptr = 5; Cout *iptr “ “ value;(7 points) Week 12, Final Attempt 3(Current Exam) 5 5 10 10 5 10 10 5 Instructor Explanation:Malik, pages 796–809 MC (TCO 4) What is wrong with the following C++ statements? int * iptr; double d = 123.321; iptr = &d; cout *iptr;(7 points) Week 12, Final Attempt 3(Current Exam) The cout statement does not contain an endl. The space following the ampersand should not be there. The iptr variable cannot be given an address of a double. All of the above Instructor Explanation:Malik, pages 809–812 MC (TCO 4) What is the output of the following code snippet? int *p; int *q; p = new int; *p = 43; q = p; *q = 52; p = new int; *p = 78; q = new int; *q = *p; cout *p " " *q end1(7 points) Week 12, Final Attempt 3(Current Exam) 4352 5278 7878 7852 Instructor Explanation:Malik, pages 796–809

Show more Read less
Institution
Course

Content preview

MC Week 12, Final Attempt 3(Current Exam)
(TCO
4)
What
is the
result
of 5
% 7?
(7
points)



0


2


5


7

Instructor Explanation: Malik, pages 39–40


MC Week 12, Final Attempt 3(Current Exam)
(TCO 4) A variable declared before and outside all function blocks (7
points)



is visible only in main.


is visible to all functions.


is visible to all functions except main.


is not visible to any functions.

Instructor Explanation: Malik, pages 50–65


MC Week 12, Final Attempt 3(Current Exam)
(TCO 4) What is the value of data after the following code
executes?
unsigned char data = 0xA5;
data = data & 0xF0;(7 points)

0xA0


0xF0


0xF5


0x5A

Instructor Explanation: Malik, pages 32–42

, MC Week 12, Final Attempt 3(Current Exam)
(TCO 4) What is the bit pattern in data after the following statements
execute?
unsigned int data = 10;
data = data | 0x0B;
data = data << 1;(7 points)

0x314


0x154


0x342


0x156

Instructor Explanation: Malik, pages 32–42


MC Week 12, Final Attempt 3(Current Exam)
(TCO 4) Why does this code snipper give a compile error?
int loopCounter = 0;
int numberOfScores = 20;
while (loopcounter < numberOfScores)
cout << “\nInside the loop”;(7 points)

The value of the control loop control variable does not change the loop body.


The curly brackets are missing around the loop body.


The loopCounter variable is not spelled consistently.


All of the above

Instructor Explanation: Malik, pages 32–42


MC Week 12, Final Attempt 3(Current Exam)
(TCO 4) Which of the following is not a C++ logical operator? (7 points)


#


&&


││


!

Instructor Explanation: Malik, pages 57–67

, MC Week 12, Final Attempt 3(Current Exam)
(TCO 4) What is the value of i after the following code fragment
executes?
int i = 2;
int k = 5 ;
i *= k + 1;(7 points)

7


11


12


14

Instructor Explanation: Malik, pages 57–67


MC Week 12, Final Attempt 3(Current Exam)
(TCO 4) Which looping statement is best if the number of iterations
is known?(7 points)

If/Else


For


While


Do/While

Instructor Explanation: Malik, pages 57–67


MC Week 12, Final Attempt 3(Current Exam)
(TCO 4) Which operation in the following expression will be
performed first?
c = a++ / b + 5;(7 points)

a


a/b


assignment to c


b+5

Instructor Explanation: Malik, pages 57–67

, MC Week 12, Final Attempt 3(Current Exam)
(TCO 4) What is the value stored in variable c, after the execution of
the following statement?
int a=5, b=2, c;
c = ++a / b + 5;(7 points)

7.5


8


7


0

Instructor Explanation: Malik, pages 57–67


MC Week 12, Final Attempt 3(Current Exam)
(TCO 4)
What is
the value
stored in
variable c,
after the
execution
of the
following
statement?

int a=5,
b=2, c;
c = a++ / b
+ 5;(7 points)

7.5


8


7


0

Instructor Explanation: Malik, pages 57–67


MC Week 12, Final Attempt 3(Current Exam)
(TCO 4) If firstName and lastName are string object variables,
which statement can be used to combine (append or
concatenate) the two into a single string variable?(7 points)

fullName = firstName + lastName;

Written for

Institution

Document information

Uploaded on
March 25, 2022
Number of pages
32
Written in
2021/2022
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$10.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
abram23 Adams State College
Follow You need to be logged in order to follow users or courses
Sold
675
Member since
5 year
Number of followers
546
Documents
3338
Last sold
1 hour ago
QUALITY WORK OF ALL KIND OF QUIZ or EXAM WITH GUARANTEE OF AN A

Im an expert on major courses especially; psychology,Nursing, Human resource Management &amp; Project writting.Assisting students with quality work is my first priority. I ensure scholarly standards in my documents . I assure a GOOD GRADE if you will use my work.

4.0

142 reviews

5
78
4
26
3
16
2
3
1
19

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions