Chapter 1 Introduction to Computer and Java

Ace your homework & exams now with Quizwiz!

Internally, the CPUc onsists of what two units?

Arithmetic and Logic Unit (ALU), and Control Unit

11. Why are Java applets safe to download and execute?

Because the browser executes them in a restricted environment.

JVM stands for __________.

Java Virtual Machine

13. What is the difference between machine language code and byte code?

Machine language code is executed directly by the CPU. Byte code is executed by the JVM.

19. Will the Java compiler translate a source file that contains syntax errors?

No

What are an object's attributes?

The data contained in an object.

What is the purpose of testing a program with sample data or input?

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.

A byte is made up of eight

bits

The Java compiler generates __________.

byte code

21. Assuming you are using the JDK, what command would you type at the operating system command prompt to compile the program LabAssignment.java?

javac LabAssignment.java

These are words that have a special meaning in the programming language.

key words

These are the rules that must be followed when writing a program.

syntax

What is a compiler?

A compiler is a program that translates source code into an executable form.

Describe what a compiler does with a program's source code.

A compiler translates source code into an executable form.

What is pseudocode?

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.

Describe the difference between a key word and a programmer-defined symbol.

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.

Describe the difference between a program line and a statement.

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.

9. What is a compiler?

A program that translates source code into executable code.

What is a runtime error?

A runtime error is an error that occurs while the program is running. These are usually logical errors, such as mathematical mistakes.

What is a memory address? What is its purpose?

A unique number assigned to each section of memory. The address is used to identify a location in memory.

8. What is an algorithm?

An algorithm is a set of well-defined steps for performing a task or solving a problem.

10. What is the difference between an application and an applet?

An application is a stand-alone program that runs on your computer. An applet is designed to be transmitted over the Internet from a Web server, and then executed in a Web browser

3. What is the difference between operating system software and application software?

An operating system is a set of programs that manages the computer's hardware devices and controls their processes. Windows and UNIX are examples of operating systems. Application software refers to programs that make the computer useful to the user. These programs solve specific problems or perform general operations that satisfy the needs of the user. Word processing, spreadsheet, and database packages are all examples of application software.

14. Why does byte code make Java a portable language?

Because Javabyte code is the same on all computers, compiled Java programs are highly portable. In fact, a compiled Java program may be run on any computer that has a JVM.

5. Why is it easier to write a program in a high-level language than in machine language?

Because machine language programs are streams of binary numbers, and high level language programs are made up of words.

Why is the computer used by so many different people, in so many different professions?

Because the computer can be programmed to do so many different tasks.

4. Why must programs written in a high-level language be translated into machine language before they can be run?

Because the computer only understand machine language.

Why are variables called "variable"?

Because their contents may be changed.

What does it mean to "visualize a program running"? What is the value of such an activity?

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.

This part of the computer fetches instructions, carries out the operations commanded by the instructions, and produces some outcome or resultant information.

CPU

In procedural programming, what two parts of a program are typically separated?

Data and the code that operates on the data.

16. Why should an object hide its data?

Data hiding ensures exclusive data access to class members and protects object integrity by preventing unintended or intended changes.

What is data hiding?

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.

What is encapsulation?

Encapsulation refers to the combining of data and code into a single object.

Describe the steps in the fetch/decode/executecycle.

Fetch: The CPU's control unit fetches the program's next instruction from main memory. 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.

What does the term multitasking mean?

It means that an operating system is capable of running multiple programs at once.

12. What must a computer have in order for it to execute Java programs?

Java Virtual Machine (JVM).

2. What type of memory is usually volatile?

Main memory RAM

1. Both main memory and secondary storage are types of memory. Describe the difference between the two.

Main memory, or RAM, holds the sequences of instructions in the programs that are running and the data those programs are using. Main memory, or RAM, is usually volatile. Secondary storage is a type of memory that can hold data for long periods of time—even when there is no power to the computer.

15. Is encapsulation a characteristic of procedural or object-oriented programming?

Object-oriented programming

Describe the difference between operators and punctuation symbols.

Operators perform operations on one or more operands. Punctuation symbols mark the beginning or ending of a statement, or separates items in a list.

Explain why computers have both main memory and secondary storage.

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.

Is a syntax error (such as misspelling a keyword) found by the compiler or when the program is running?

Syntax errors are found by the compiler.

7. What is the difference between a syntax error and a logical error?

Syntax errors are mistakes that the programmer has made that violate the rules of the programming language. Logical errors are mistakes that cause the program to produce erroneous results.

What is a syntax error?

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.

List the five major hardware components of a computer system.

The Central Processing Unit (CPU), main memory, secondary storage devices, input devices, output devices.

What is the JVM?

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.

What is byte code?

The Java compiler translates Java source code into byte code, which is an intermediate language. The Java Virtual Machine executes the byte code instructions.

17. What part of an object forms an interface through which outside code may access the object's data?

The object's methods.

What happens to a variable's current contents when a new value is stored there?

The original value is overwritten.

What are an object's methods?

The procedures, or behaviors, that an object performs.

What four items should you identify when defining what a program is to do?

The program's purpose, input, process, and output.

18. What type of program do you use to write Java source code?

You can use any text editor to create and edit source files.

If you were to look at a machine language program, you would see _________.

a stream of binary numbers

6. What is a source file?

a text listing of commands to be compiled or assembled into an executable computer program.

22. Assuming there are no syntax errors in the LabAssignment.java program when it is compiled, answer the following questions. a. What file will be produced? b. What will the file contain? c. What command would you type at the operating system command prompt to run the program?

a. LabAssignment.class b. byte code c. java LabAssignment

Each byte is assigned a unique

address

This type of program is designed to be transmitted over the Internet and run in a Web browser.

applet

These are symbols or words that perform operations on one or more operands.

operators

These are words or names that are used to identify storage locations in memory and parts of the program that are created by the programmer.

programmer-defined names

These characters serve specific purposes, such as marking the beginning or ending of a statement, or separating items in a list.

punctuation

This type of memory can hold data for long periods of time—even when there is no power to the computer.

secondary storage

20. What does the Java compiler translate Java source code to?

the compiler will translate it to byte code.

This is a named storage location in the computer's memory.

variable


Related study sets

Glosario Técnico Construcción.

View Set

Org Behavior Ch 13: Organizational Structure and Culture

View Set

Chapter 11. Pricing Products and Services

View Set