Computer Science 2023 What Is The Value Of Data After The Following Code Executes?
2023 Top of Form Question 1 1 TCO 2 What is the value | Assignment Collections
Question 1. 1. (TCO 2) What is the value ofdata after the following code executes? unsigned char data = 0xA5; data = data & 0xF0; (Points : 6)
|
0xA0 0xF0 0xF5 0x5A
|
Question 2. 2. (TCO 2) 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? (Points : 6)
|
fullName = firstName + lastName; fullName = firstName, lastName; fullName = firstName & lastName; fullName = firstName && lastName;
|
Question 3. 3. (TCO 2) For a switch statement, which of the following case statement expressions is invalid or logically incorrect? (Points : 6)
|
case 1 < x < 100; case ‘B’|’b’; case a23.45 All of the above
|
Question 4. 4. (TCO 2) What output does the following code produce? cout << fixed << setprecision(3); double pi = 3.14159; cout << pi << endl; (Points : 6)
|
3.14159 3.142 3.14 none of the above
|
Question 5. 5. (TCO 2) What is the value of i after the following code fragment executes? int i = 2; int k = 5 ; i *= k + 1; (Points : 6)
|
7 11 12 14
|
Question 6. 6. (TCO 2) What is the data type of bullpen[3].era? struct pitcher { string name; double era; }; pitcher p1; pitcher bullpen[10]; (Points : 6)
|
string double pitcher const pointer to pitcher
|
Question 7. 7. (TCO 2) 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]; (Points : 6)
|
string const pointer to student student double
|
Question 8. 8. (TCO 2) Given the following code fragment, what is the data type of thisStudent? struct student { string name; double gpa; }; student thisStudent; (Points : 6)
|
string const pointer to student student double
|
Question 9. 9. (TCO 2) Which of the following statements calls the following function correctly? int MultiplyValues (int, int); (Points : 6)
|
int a = MultiplyValues (int x, int y); int a = MultiplyValues (10, 20); double d = MultiplyValues (int 10, int 20); All of the above
|
|
|
Question 10. 10. (TCO 2) 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; }
int main () { int x[ ] = {1, 2, 3}; func(x); cout << x[0] << ” ” << x[1] << ” ” << x[2] << endl; } (Points : 6)
|
1 2 3 3 4 5 3 6 9 3 3 3
|
Question 11. 11. (TCO 2) Which of the following function definitions uses pass-by-values? (Points : 6)
|
int myFunc( int * x, int * y ); int myFunc( int x, int y ) ; int myFunc( int & x, int & y ) ; int myFunc( int @value1, int @value2 ) ;
|
|
Page 2
Question 1. 1. (TCO 2) How many parameters are required to overload the pre-increment operator for a class as a member function? (Points : 6)
|
none 1 2 no limit
|
Question 2. 2. (TCO 2) 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)? (Points : 6)
|
Set Private Member Accessor
|
Question 3. 3. (TCO 2) Which of the following is a valid declaration to overload the following function? int whatever (double x); (Points : 6)
|
double whatever (double x); int whatever (int x); int whatever2 (double x); int overload (double x);
|
Question 4. 4. (TCO 2) Variables defined to be of a user-declared class are referred to as: (Points : 6)
|
attributes member variables primitive variables objects
|
Question 5. 5. (TCO 2) When organizing a program into three files (main, class implementation, and class header), which is not a .cpp file? (Points : 6)
|
main none are .cpp class header class implementation
|
Question 6. 6. (TCO 2) What is the data type of pDist for the code snippet below? Distance * pDIST; (Points : 6)
|
Distance Const pointer to Distance Pointer to Distance None of the above
|
Question 7. 7. (TCO 2) What is the output of the following code snippet? int value = 10; int * iptr = &value; *iptr = 5; Cout << *iptr << “ “ << value; (Points : 6)
|
5 5 10 10 5 10 10 5
|
Question 8. 8. (TCO 2) What is wrong with the following C++ statements? int * iptr; double d = 123.321; iptr = &d; cout << *iptr; (Points : 6)
|
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
|
Question 9. 9. (TCO 2) What does the following Java code do? JPanel pane = new JPanel( ); pane.setLayout( new gridLayout(2, 3) ); (Points : 6)
|
Creates a panel which will organize its components into 5 distinct cells. Creates a panel which displays a grid containing the numbers 2 and 3. Creates a panel which will organize its components into two rows of three columns. None of the above.
|
Question 10. 10. (TCO 2) Which of the following is an example of the invocation of a static method in Java? (Points : 6)
|
Integer.parseInt(someString); Math.pow(2, 3); String.format(“This is an output string”); All of the above
|
Question 11. 11. (TCO 2) Which Java interface would you need to implement in order to handle events such as key pressed or key released events? (Points : 6)
|
KeyListener interface KeyStroke interface KeyEvent interface This information is not available in a Java program
|
Question 12. 12. (TCO 2) What can you say about the following Java class? Public class MyApp extends JFrame ( …) (Points : 6)
|
MyApp is a Java application. MyApp implements the JFrame interface. MyApp inherits from the JFrame class. MyApp has a nested inner class called JFrame.
|
Question 13. 13. (TCO 2) The Graphics class in Java provides methods to: (Points : 6)
|
draw lines between any two points draw test strings starting at any point draw shapes such as rectangles, ovals, etc. All of the above
|
Question 14. 14. (TCO 2) The x, y drawing coordinate system used in Java graphics (Points : 6)
|
uses character units. has the origin in the upper left corner of the display area. uses the x coordinate for the vertical axis. All of the above
|
|
Page 1
Question 1. 1. (TCO 2) Which of the following is not a C++ logical operator? (Points : 6)
|
# && „„ !
|
Question 2. 2. (TCO 2) What is wrong with the following switch statement? switch(x) { case 0: cout << x; case 2: cout << 2 / x; break; default: cout << “error”; break; } (Points : 6)
|
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
|
Question 3. 3. (TCO 2) Why does this code snippet give a compile error? int loopCounter = 0; numberOfScores = 20; while (loopcounter < numberOfScores) cout << “nInside the loop”; (Points : 6)
|
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
|
Question 4. 4. (TCO 2) Which operation in the following expression will be performed first? c = a++ / b + 5; (Points : 6)
|
a++. a/b assignment to c b + 5
|
Question 5. 5. (TCO 2) Which looping statement is best if the number of iterations is known? (Points : 6)
|
if/else for while do/while
|
Question 6. 6. (TCO 2) 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]; (Points : 6)
|
string const pointer to student student double
|
Question 7. 7. (TCO 2) 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; } (Points : 6)
|
Compiler, due to out-of-bounds array subscript. Run-time, due to out-of-bounds array subscript. Compiler, due to invalid array initialization. None of the above. It does not create any type of error.
|
Question 8. 8. (TCO 2) How many elements does the following array contain? double data [100] [500]; (Points : 6)
|
500 100 600 50,000
|
Question 9. 9. (TCO 2) Which of the following functions is taking an array of MyStruct structures as a pass-by-value parameter? (Points : 6)
|
void MyFunc( MyStruct data[ ] ); void MyFunc( MyStruct &data[ ] ); void MyFunc( MyStruct *data[ ] ) ; not allowed in C++
|
Question 10. 10. (TCO 2) 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; } (Points : 6)
|
20 30 10 5
|
Question 11. 11. (TCO 2) 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 ; } (Points : 6)
|
20 30 10 5
|
|
Page 2
Question 1. 1. (TCO 2) Which of the following is a valid declaration to overload the following function? int whatever (double x); (Points : 6)
|
double whatever (double x); int whatever (int x); int whatever2 (double x); int overload (double x);
|
Question 2. 2. (TCO 2) The word const inside the parentheses of the following declaration of isEqual bool isEqual (const Distance & rightSideObject) const; (Points : 6)
|
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
|
Question 3. 3. (TCO 2) How many parameters are required to overload the pre-increment operator for a class as a member function? (Points : 6)
|
none 1 2 no limit
|
Question 4. 4. (TCO 2) Which of the following is called automatically each time an object is created? (Points : 6)
|
Compiler Builder Constructor Destructor
|
Question 5. 5. (TCO 2) 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 d1.feet = 5; //Line 6 // etc. – assume the remaining code is correct } (Points : 6)
|
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
|
Question 6. 6. (TCO 2) What is the data type of pDist for the code snippet below? Distance * pDIST; (Points : 6)
|
Distance Const pointer to Distance Pointer to Distance None of the above
|
Question 7. 7. (TCO 2) Given the definition of some class called Employee, which of the following correctly dynamically allocates an array of 20 Employee objects? (Points : 6)
|
Employee * myData = new Employee[20]; Employee myData[20] = new Employee[20]; Employee = myData[20]; Employee array = new Employee[20];
|
Question 8. 8. (TCO 2) What is the output of the following code snippet? int value = 10; int * iptr = &value; *iptr = 5; Cout << *iptr << “ “ << value; (Points : 6)
|
5 5 10 10 5 10 10 5
|
Question 9. 9. (TCO 2) Which of the following Java statements creates an object of a ButtonHandler class (which implements the ItemListener interface) and associates it with a JRadioButton object called buttonOne? (Points : 6)
|
buttonOne.addItemListener(ButtonHandler( )); buttonOne.addItemListener(new ButtonHandler()); buttonOne.+= new ButtonHandler( ); buttonOne.addEventHandlerr(new ButtonHandler( ));
|
Question 10. 10. (TCO 2) Which of the following creates a class that properly handles ActionEvents? (Points : 6)
|
class handler implements ActionListener {public void actionPerformed(ActionEvent e){//code for event handler} } class handler extends ActionListener {public void handleEvent(ActionEvent e){//code for event handler} } class handler implements ActionListener {public void ActionListener(ButtonEvent e){//code for event handler} } class handler implements ActionListener {public void actionPerformed(ActionListener e){//code for event handler} }
|
Question 11. 11. (TCO 2) The x, y drawing coordinate system used in Java graphics (Points : 6)
|
uses character units. has the origin in the upper left corner of the display area. uses the x coordinate for the vertical axis. All of the above
|
Question 12. 12. (TCO 2) In order to guarantee that only one JRadioButton is selected at any time: (Points : 6)
|
add each JRadioButton object to a different panel create a ButtonGroup object and add the JRadioBttons to it have a JCheckBox object manage the three JRadioButtons This cannot be done in Java.
|
Question 13. 13. (TCO 2) What can you say about the following Java class? Public class MyApp extends JFrame ( …) (Points : 6)
|
MyApp is a Java application. MyApp implements the JFrame interface. MyApp inherits from the JFrame class. MyApp has a nested inner class called JFrame.
|
Question 14. 14. (TCO 2) What is the result of the following code? JFrame frame = new JFrame( ); frame.add(new JButton(“One”), BorderLayout.NORTH); frame.add(new JButton(“Two”), BorderLayout.NORTH); frame.setVisible(true); (Points : 6)
|
Two buttons are added side by side at the top of the display. Button One was added first, so it is the only button at the top of the display. Button Two was added last, so it is the only button at the top of the display. The Java compiler will not allow you to add two buttons to the same area.
|
|
We give our students 100% satisfaction with their assignments, which is one of the most important reasons students prefer us to other helpers. Our professional group and planners have more than ten years of rich experience. The only reason is that we have successfully helped more than 100000 students with their assignments on our inception days. Our expert group has more than 2200 professionals in different topics, and that is not all; we get more than 300 jobs every day more than 90% of the assignment get the conversion for payment.
#write essay #research paper #blog writing #article writing #academic writer #reflective paper #essay pro #types of essays #write my essay #reflective essay #paper writer #essay writing service #essay writer free #essay helper #write my paper #assignment writer #write my essay for me #write an essay for me #uk essay #thesis writer #dissertation writing services #writing a research paper #academic essay #dissertation help #easy essay #do my essay #paper writing service #buy essay #essay writing help #essay service #dissertation writing #online essay writer #write my paper for me #types of essay writing #essay writing website #write my essay for free #reflective report #type my essay #thesis writing services #write paper for me #research paper writing service #essay paper #professional essay writers #write my essay online #essay help online #write my research paper #dissertation writing help #websites that write papers for you for free #write my essay for me cheap #pay someone to write my paper #pay someone to write my research paper
#Essaywriting #Academicwriting #Assignmenthelp #Nursingassignment #Nursinghomework #Psychologyassignment #Physicsassignment #Philosophyassignment #Religionassignment #History #Writing #writingtips #Students #universityassignment #onlinewriting #savvyessaywriters #onlineprowriters #assignmentcollection #excelsiorwriters #writinghub #study #exclusivewritings #myassignmentgeek #expertwriters #art #transcription #grammer #college #highschool #StudentsHelpingStudents #studentshirt #StudentShoe #StudentShoes #studentshoponline #studentshopping #studentshouse #StudentShoutout #studentshowcase2017 #StudentsHub #studentsieuczy #StudentsIn #studentsinberlin #studentsinbusiness #StudentsInDubai #studentsininternational