CSC Ch 1
1.1 Why is the computer used by so many different people, in so many different professions?
1.1 Because the computer can be programmed to do so many different tasks.
1.10 Describe the difference between a program line and a statement.
1.10 A line is a single line as it appears in the body of a program. A statement is a complete instruction that causes the computer to perform an action.
1.11 Why are variables called " variable"?
1.11 Because their contents may be changed.
1.12 What happens to a variable's current contents when a new value is stored there?
1.12 The original value is overwritten.
1.13 What is a compiler?
1.13 A compiler is a program that translates source code into an executable form.
1.14 What is a syntax error?
1.14 Syntax errors are mistakes that the programmer has made that violate the rules of the programming language. These errors must be corrected before the compiler can translate the source code.
1.15 What is byte code?
1.15 The Java compiler translates Java source code into byte code, which is an intermediate language. The Java Virtual Machine executes the byte code instructions.
1.16 What is the JVM?
1.16 The Java Virtual Machine (JVM) is a program that reads Java byte code instructions and executes them as they are read. In other words, it interprets byte code instructions. You can think of the JVM as a program that simulates a computer whose machine language is Java byte code.
1.17 What four items should you identify when defining what a program is to do?
1.17 The program's purpose, input, process, and output.
1.18 What does it mean to " visualize a program running"? What is the value of such an activity?
1.18 Before you create a program on the computer, it is often a good idea to imagine what the computer screen will look like while the program is running. If it helps, draw pictures of the screen, with sample input and output, at various points in the program.
1.19 What is pseudocode?
1.19 A cross between human language and a programming language. Pseudocode is especially helpful when designing an algorithm. Although the computer can't understand pseudocode, programmers often find it helpful to write an algorithm in a language that's "almost" a programming language, but still very similar to natural language.
1.2 List the five major hardware components of a computer system.
1.2 The Central Processing Unit (CPU), main memory, secondary storage devices, input devices, output devices.
1.20 Describe what a compiler does with a program's source code.
1.20 A compiler translates source code into an executable form.
1.21 What is a runtime error?
1.21 A runtime error is an error that occurs while the program is running. These are usually logical errors, such as mathematical mistakes.
1.22 Is a syntax error ( such as misspelling a key word) found by the compiler or when the program is running?
1.22 Syntax errors are found by the compiler.
1.23 What is the purpose of testing a program with sample data or input?
1.23 You can provide sample data and predict what the output should be. If the program does not produce the correct output, a logical error is present in the program.
1.24 In procedural programming, what two parts of a program are typically separated?
1.24 Data and the code that operates on the data.
1.25 What are an object's attributes?
1.25 The data contained in an object.
1.26 What are an object's methods?
1.26 The procedures, or behaviors, that an object performs.
1.27 What is encapsulation?
1.27 Encapsulation refers to the combining of data and code into a single object.
1.28 What is data hiding?
1.28 Data hiding refers to an object's ability to hide its data from code that is outside the object. Only the object's methods may then directly access and make changes to the object's data. An object typically hides its data, but allows outside code to access the methods that operate on the data.
1.3 Internally, the CPU consists of what two units?
1.3 Arithmetic and Logic Unit (ALU), and Control Unit
1.4 Describe the steps in the fetch/ decode/ execute cycle.
1.4 Fetch: The CPU's control unit fetches the program's next instruction from main Decode: The control unit decodes the instruction, which is encoded in the form of a number. An electrical signal is generated. Execute: The signal is routed to the appropriate component of the computer, which causes a device to perform an operation. memory.
1.5 What is a memory address? What is its purpose?
1.5 A unique number assigned to each section of memory. The address is used to identify a location in memory.
1.6 Explain why computers have both main memory and secondary storage.
1.6 Program instructions and data are stored in main memory while the program is operating. Main memory is volatile, and loses its contents when power is removed from the computer. Secondary storage holds data for long periods of time—even when there is no power to the computer.
1.7 What does the term multitasking mean?
1.7 It means that an operating system is capable of running multiple programs at once.
1.8 Describe the difference between a key word and a programmer- defined symbol.
1.8 A key word has a special purpose, and is defined as part of a programming language. A programmer-defined symbol is a word or name defined by the programmer.
1.9 Describe the difference between operators and punctuation symbols.
1.9 Operators perform operations on one or more operands. Punctuation symbols mark the beginning or ending of a statement, or separates items in a list.