Chapter 1 - Creating Java Programs Flashcards

1
Q

The most basic circuitry-level computer language is _______ .

machine language

Java

high-level language

C++
A

machine language

All computer programs, even high-level language programs, ultimately are converted to the lowest-level language, which is machine language. Machine language , or machine code , is the most basic set of instructions that a computer can execute. Each type of processor (the internal hardware that handles computer instructions) has its own set of machine language instructions. Programmers often describe machine language using 1s and 0s to represent the on-and-off circuitry of computer systems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Languages that let you use an easily understood vocabulary of descriptive terms, such as read, write, or add, are known as languages.

procedural

high-level

machine

object-oriented
A

high-level

A high-level programming language such as Java, Visual Basic, C++, or C# allows you to use English-like, easy-to-remember terms such as read, write, and add.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The rules of a programming language constitute its ________ .

syntax

logic

format

objects
A

syntax

Every programming language has its own syntax , or rules about how language elements are combined correctly to produce usable statements. For example, depending on the specific high-level language, you might use the verb print or write to produce output. All languages have a specific, limited vocabulary (the language’s keywords ) and a specific set of rules for using that vocabulary. When you are learning a computer programming language, such as Java, C++, or Visual Basic, you are learning the vocabulary and syntax for that language.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

A _______ translates high-level language statements into machine code.

programmer

syntax detector

compiler

decipherer
A

compiler

After the program statements are written in a high-level programming language, a computer program called a compiler or interpreter translates the statements into machine language. A compiler translates an entire program before carrying out any statements, or executing them, whereas an interpreter translates one program statement at a time, executing a statement as soon as it is translated.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Named computer memory locations are called _______ .

compilers

variables

addresses

appellations
A

variables

The typical procedural program defines and uses named computer memory locations; each of these named locations that can hold data is called a variable . For example, data might be read from an input device and stored in a location the programmer has named rateOfPay. The variable value might be used in an arithmetic statement, used as the basis for a decision, sent to an output device, or have other operations performed with it. The data stored in a variable can change, or vary, during a program’s execution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The individual operations used in a computer program are often grouped into logical units called _______ .

procedures

variables

constants

logistics
A

procedures

the individual operations used in a computer program are often grouped into logical units called procedures . For example, a series of four or five comparisons and calculations that together determine a person’s federal withholding tax value might be grouped as a procedure named calculateFederalWithholding(). (As a convention, this course will show parentheses following every procedure name.) As a procedural program executes its statements, it can sometimes pause to call a procedure . When a program calls a procedure, the current logic is temporarily suspended so that the procedure’s commands can execute. A single procedural program might contain any number of procedure calls. Procedures are also called modules, methods, functions, and subroutines. Users of different programming languages tend to use different terms. As you will learn later in this chapter, Java programmers most frequently use the term method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Envisioning program components as objects that are similar to concrete objects in the real world is the hallmark of _______ .

command-line operating systems

procedural programming

object-oriented programming

machine languages
A

object-oriented programming

programs that use a style of programming that involves creating classes, creating objects from those classes, and creating applications that use those objects. Contrast with procedural programming. Object-oriented programming is an extension of procedural programming in which you take a slightly different approach to writing computer programs.

Creating classes, which are blueprints for objects

Creating objects, which are specific instances of those classes

Creating applications that manipulate or use those objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

The values of an object’s attributes are known as its _______ .

state

orientation

methods

condition
A

state

The values of the properties of an object are referred to as the object’s state . In other words, you can think of objects as roughly equivalent to nouns (words that describe a person, place, or thing), and of their attributes as similar to adjectives that describe the nouns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

An instance of a class is a(n) _____ .

method

procedure

object

case
A

object

An object is a specific, concrete instance of a class. Creating an instance is called instantiation . You can create objects from classes that you write and from classes written by other programmers, including Java’s creators. The values contained in an object’s properties often differentiate instances of the same class from one another. For example, the class Automobile describes what Automobile objects are like. Some properties of the Automobile class are make, model, year, and color.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Java is architecturally _____ .

neutral

oriented

specific

abstract
A

neutral

Some of the advantages that make Java a popular language are its security features and the fact that it is architecturally neutral . In other words, unlike many other languages, you can use Java to write a program that runs on any operating system (such as Windows, macOS, or Linux) or any device (such as PCs, phones, and tablet computers).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

You must compile classes written in Java into _____ .

bytecode

source code

Javadoc statements

object code
A

bytecode

The Java compiler converts the source code into a binary program of bytecode .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

All Java programming statements must end with a _____ .

period

comma

closing parenthesis

semicolon
A

semicolon

all Java program statements must end with a semicolon.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Arguments to methods always appear within ______ .

parentheses

double quotation marks

single quotation marks

curly braces
A

parentheses

System.out.println(“First Java application”);

The string within quotation marks, “First Java application”, appears within parentheses because the string is an argument to a method, and arguments to methods always appear within parentheses following the method name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

In a Java program, you must use _____ to separate classes, objects, and methods.

commas

semicolons

dots

forward slashes
A

dots

System.out.println();

The dots (periods) in System.out.println() are used to separate the names of the components in the statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

All Java applications must have a method named _____ .

method()

main()

java()

Hello()
A

main()

The name of the method is main(). As is the convention with Java methods, its identifier begins with a lowercase letter. Not all classes have a main() method; in fact, many do not. All Java applications, however, must include a class containing a public method named main(), and most Java applications have additional classes and methods. When you execute a Java application, the JVM always executes the main() method first.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Nonexecuting program statements that provide documentation are called _____ .

classes

notes

comments

commands
A

comments

Program comments are nonexecuting statements that you add to a program for the purpose of documentation. In other words, comments are designed for people reading the source code and not for the computer executing the program.

Programmers use comments to leave notes for themselves and for others who might read their programs in the future. At the very least, your Java class files should include comments indicating the author, the date, and the class name or function. The best practice dictates that you also include a brief comment to describe the purpose of each method you create within a class.

17
Q

Java supports three types of comments: _____ , _____ , and Javadoc.

line, block

string, literal

constant, variable

single, multiple
A

line, block

Java supports three types of comments:

  • Line comments start with two forward slashes ( // ) and continue to the end of the current line. A line comment can appear on a line by itself or at the end (and to the right) of a line following executable code. Line comments do not require an ending symbol.
  • Block comments start with a forward slash and an asterisk ( /* ) and end with an asterisk and a forward slash ( */ ). A block comment can appear on a line by itself, on a line before executable code, or on a line after executable code. Block comments also can extend across as many lines as needed.
  • Javadoc comments are a special case of block comments called documentation comments because they are used to automatically generate nicely formatted program documentation with a program named Javadoc. Javadoc comments begin with a forward slash and two asterisks ( /** ) and end with an asterisk and a forward slash ( */ ). Appendix E teaches you how to create Javadoc comments.
18
Q

Which of the following is not necessary to do before you can run a Java program?

coding

compiling

saving

debugging
A

debugging

Repairing all syntax errors is the first part of the process of debugging a program—freeing the program of all flaws or errors, also known as bugs .

19
Q

The command to execute a compiled Java application is _____ .

run

execute

javac

java
A

javac

this is a command line compiler; if using an IDE then you would not need to use the command prompt to compile the program

20
Q

You save text files containing Java source code using the file extension _____ .

.java

.class

.txt

.src
A

.java

When you write a Java class, you must save it using a writable storage medium such as a disk, DVD, or USB device. In Java, if a class is public (that is, if you use the public access specifier before the class name), you must save the class in a file with exactly the same name and a .java extension. For example, the First class must be stored in a file named First.java. The class name and filename must match exactly, including the use of uppercase and lowercase characters. If the extension is not .java, the Java compiler does not recognize the file as containing a Java class.