Folder101   Home Notes Quiz Assigns Info  
Forum Forum
101 Home 101
 
  C++ Level 2

Practice Test 2


There are 20 questions in this quiz

Question 1: Multiple Choice       

Which of the following statements is false about data-types in C++:

Choice 1 an unsigned short int is usually 2 bytes and doesn't include negative numbers
Choice 2 a signed short int is normally 2 bytes and does include negative numbers
Choice 3 a char is normally 1 byte - there are 256 different characters to choose from
Choice 4 both signed and unsigned int's are normally 8 bytes

Question 2: Multiple Choice       

Combining object code with any other object files and/or library files that may be necessary to make a stand-alone executable file is carried out by the...

Choice 1 compiler
Choice 2 linker
Choice 3 preprocessor
Choice 4 editor

Question 3: Multiple Choice       

Which of the following statements is false?

Choice 1 reserved words in C++ are keywords such as const
Choice 2 int is a keyword and so is reserved
Choice 3 variable names are keywords
Choice 4 variable Identifiers MUST begin with a letter

Question 4: Multiple Choice      

Which one of the following statements is false?

Choice 1 The remainder operator (%) can operate on real numbers
Choice 2 The escape sequence that produces a bell sound is \a
Choice 3 dividing an integer by another integer results in an integer
Choice 4 dividing an integer by a real number results in a real number

Question 5: Multiple Choice       

Which one of the following produces an integer result?

Choice 1 3.0 + 5 / 2
Choice 2 5 / 2.0
Choice 3 2.0 / 2
Choice 4 3 + 5 / 2

Question 6: Multiple Choice     

The function atoi() returns the type:

Choice 1 float
Choice 2 integer
Choice 3 double
Choice 4 char

Question 7: Multiple Choice       

An #include directive instucts the...

Choice 1 compiler to include a file, such as a library
Choice 2 preprocessor to include a constant value
Choice 3 compiler to include include a constant value
Choice 4 preprocessor to include a file, such as a library

Question 8: Multiple Choice       

Which library file is needed for sending and receiving keyboard input?

Choice 1 stdio.h
Choice 2 conio.h
Choice 3 iostream.h
Choice 4 stdlib.h

Question 9: Multiple Choice       

What output is produced by the code shown below?

      const int MAX = 5;
      int x = 12;
      x -= MAX;
      cout << x;

Choice 1 7
Choice 2 -12
Choice 3 -5
Choice 4 5

Question 10: Multiple Choice       

Which one of the following comments about the evaluated expression is incorrect?

Choice 1 ( 1 + 5) % 3 * 2 - 2     // expresion returns -2
Choice 2 2 - 10 % 4      // expresion returns 0
Choice 3 6 + 3 / 2      // expresion returns 7
Choice 4 100 / 5 / 2 % 7       // expresion returns 10

Question 11: Multiple Choice       

What output is produced by the code shown below?

      const char LETTER = 'B';
      int x = LETTER;
      cout << x + 2;

Choice 1 95
Choice 2 67
Choice 3 68
Choice 4 103

Question 12: Multiple Choice       

Which line of code produces a compiler error?

      1. const char LETTER = 'd';
      2. int x = 3;
      3. LETTER = x + 1;
      4. cout << LETTER;

Choice 1 1
Choice 2 2
Choice 3 3
Choice 4 4

Question 13: Multiple Choice       

What output is produced by the code shown below?

      char LETTER = 'a';
      LETTER += 2;
      cout << LETTER;

Choice 1 b
Choice 2 c
Choice 3 99
Choice 4 100

Question 14: Multiple Choice       

Which one of the following logical expressions returns FALSE?

Choice 1 5 + 10< 3 && 7 + 3 <= 20
Choice 2 !(3 % 1)
Choice 3 'a' != 'b' - 2
Choice 4 !0 || !1

Question 15: Multiple Choice       

What output is produced by the following code?

     int x = 12, y = 5;
     if (x > 12) {
          if ( x < 15)
               cout << "BLUE";
      }
     else if ( y > 4)
          cout << "GREEN";
     else
          cout << "YELLOW";
     cout << "EGGS";

Choice 1 EGGS
Choice 2 BLUE EGGS
Choice 3 GREEN EGGS
Choice 4 YELLOW EGGS

Question 16: Multiple Choice       

What output is produced by the following code?

     if ('10' != '12' - 2 || 'A' < 'B')
    
     cout << "YES";
     else
          cout << "NO";

Choice 1 a compiler error
Choice 2 YES
Choice 3 NO
Choice 4 a run-time error

Question 17: Multiple Choice       

What output is produced by the following code?

     char ch;
     
for (int i = 0; i >=-3; i--){
          ch = 67 + i;
          cout << ch << ",";
      }

Choice 1 67,68,69,
Choice 2 67,66,65,
Choice 3 C,D,E,
Choice 4 C,B,A,

Question 18: Multiple Choice       

What is the last line of output is produced by the following code?

     for (int i = 1, k = 1; i <= 8; i += 2, k++)
          cout << i*k << endl;

Choice 1 28
Choice 2 15
Choice 3 6
Choice 4 1

Question 19: Multiple Choice       

Which one of the following is a post-conditional loop?

Choice 1 for
Choice 2 while
Choice 3 switch
Choice 4 do...while

Question 20: Multiple Choice       

Which one of the following is a loop construct which will always be executed at least once?

Choice 1 for
Choice 2 while
Choice 3 switch
Choice 4 do...while