Study Guide 1: Basics

  1. Match the term with the correct definition:
    • Analysis
    • Design
    • Programming
    • Produces a usable tool or system.
    • Focuses on the problem rather than the solution.
    • Forms a solution architecture.
  2. Match the programming paradigm with the correct description:
    • Procedural
    • Data Driven
    • Object-Oriented
    • Follows the data through a system.
    • Encapsulated data and operations together.
    • Decomposes a problem into smaller problems.
  3. Java is a pure object-oriented language, meaning that all data and operations must be defined inside a class.
    1. True
    2. False
  4. C++ is a hybrid language, meaning that data and operations may be defined inside or outside a class.
    1. True
    2. False
  5. A C++ instruction that tells the computer to do something is called a(n) _____ .
    1. expression
    2. statement
    3. declaration
    4. definition
  6. Code that results in a value is called a(n) ___________ .
    1. expression
    2. statement
    3. declaration
    4. definition
  7. A(n) __________ causes the compiler to allocate memory.
    1. expression
    2. statement
    3. declaration
    4. definition
  8. A(n) __________ introduces an identifier to the program, which is placed in the compiler's symbol table along with typing information.
    1. expression
    2. statement
    3. declaration
    4. definition
  9. A C++ variable of type char can hold the numeric value 301.
    1. true
    2. false
  10. What kind of program element is 12?
    1. integer constant
    2. character constant
    3. float constant
    4. double constant
    5. variable name or identifier
    6. function name
    7. a string constant or string literal
    8. malformed or otherwise incorrect code
  11. What kind of program element is 'a'?
    1. integer constant
    2. character constant
    3. float constant
    4. double constant
    5. variable name or identifier
    6. function name
    7. a string constant or string literal
    8. malformed or otherwise incorrect code
  12. What kind of program element is "a"?
    1. integer constant
    2. character constant
    3. float constant
    4. double constant
    5. variable name or identifier
    6. function name
    7. a string constant or string literal
    8. malformed or otherwise incorrect code
  13. What kind of program element is 4.28915 (the question is about how the compiler treats the constant, not the type in which the value will fit)?
    1. integer constant
    2. character constant
    3. float constant
    4. double constant
    5. variable name or identifier
    6. function name
    7. a string constant or string literal
    8. malformed or otherwise incorrect code
  14. What kind of program element is FooBar?
    1. integer constant
    2. character constant
    3. float constant
    4. double constant
    5. variable name or identifier
    6. function name
    7. a string constant or string literal
    8. malformed or otherwise incorrect code
  15. What kind of program element is FooBar()?
    1. integer constant
    2. character constant
    3. float constant
    4. double constant
    5. variable name or identifier
    6. function name
    7. a string constant or string literal
    8. malformed or otherwise incorrect code
  16. What kind of program element is 0xAF?
    1. integer constant
    2. character constant
    3. float constant
    4. double constant
    5. variable name or identifier
    6. function name
    7. malformed or otherwise incorrect code
  17. What if anything is wrong with the expression ' x '?
    1. There is nothing wrong with the expression
    2. Spaces inside of single quotation marks are not allowed
    3. There are too many characters inside the quotation marks
  18. What if anything is wrong with the expression '\n'?
    1. There is nothing wrong with the expression
    2. Spaces inside of single quotation marks are not allowed
    3. There are too many characters inside the quotation marks
  19. Which of the following IS a VALID variable name?
    1. index 2
    2. index-2
    3. 2index
    4. counter_2_index
  20. Choose the correct description of the following two lines of code.
    #include <header1>
    #include "header2.h"
    1. Look for header1 in the current directory and header2.h where system header files are stored
    2. Look for header1 where system header files are stored and header2.h in the current directory
    3. header1 is a program-specific header file
    4. header2.h is a system header file
  21. Which of the following programs are executed by an IDE (integrated development environment) to convert program source code into an executable program? (Mark all that apply.)
    1. text editor
    2. preprocessor
    3. compiler component
    4. linker
    5. debugger
  22. A function name must be followed by ______ .
    1. { and }
    2. [ and ]
    3. ( and )
    4. < and >
  23. A function body is delimited by ______ .
    1. { and }
    2. [ and ]
    3. ( and )
    4. < and >
  24. Match the statements to the best description:
    • double counter;
    • counter = 0;
    • double counter = 0;
    • Defines and initializes a variable
    • Defines a variable
    • Initializes a variable
  25. Order the steps necessary to use a variable in a computer program:
    • Step 1:
    • Step 2:
    • Step 3:
    • Use the variable in some way
    • Define the variable
    • Initialize the variable (i.e., assign or store the first value into the variable)
  26. Memory to store a static variable is allocated when the program is loaded into memory and remains allocated until the program terminates. That means that programmers can use the variable name anywhere in the program.
    1. True
    2. False
  27. Write a statement to define (just define, not initialize) a variable named total that is type double.

     

  28. Write a statement to define AND initialize to 0 (zero) a variable named sum that is type int.

     

  29. Which code fragment(s) demonstrate code that has been "commented out?"
    1. /*int main()
      {
      	. . .
      	return 0;
      }*/
    2. statement1;
      //statement2;  // does something neat
      statement3;
      statement4;
    3. Both a and b have code that is commented out.
    4. Neither example demonstrates commented-out code.