Chapter 2 Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

structure

A

Building ideas together so that a complex program involves a simple set of smaller parts combined.

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

coding

A

would then refer to filling in

the details of that design.

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

syntax

A

The rules that determine what is allowed in a programming language. Syntax rules specify the basic vocabulary of the language and how programs can be constructed using things like loops, branches, and subroutines. A syntactically correct program is one that
can be successfully compiled or interpreted; programs that have syntax errors will be rejected
(hopefully with a useful error message that will help you fix the problem).

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

semantics

A

Ensuring that the meaning of the results is correct or follows the logical assumptions of what the answer should be.

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

pragmantics/style

A

ensuring that the design of a program visually makes sense to the user.

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

subroutine call statement

A

It uses a “built-in subroutine”
named System.out.println to do the actual work. Recall that a subroutine consists of the
instructions for performing some task, chunked together and given a name. That name can be
used to “call” the subroutine whenever that task needs to be performed.

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

built-in subroutine

A

is one that is already defined as part of the language and therefore automatically available for use in any program.

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

comments

A

Comments in a program are entirely ignored by the computer; they are there for human readers only. // or starts with /* and ends with */

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

class

A
Not every class is a program. In order to define a program, a class
must include a subroutine named main, with a definition that takes the form:

public static void main(String[] args) {
{ statements }
}

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

public

A

used in the first line of main() means that the routine can be called from outside the program. This is essential because the main() routine is called by the Java interpreter,
which is something external to the program itself

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

where is the subroutine located in a Java program?

A

between { and }.

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

packages

A

A package is a group of classes.

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

Class and file name rules

A

If the name of the class is HelloWorld, then the class must be saved in a file called HelloWorld.java

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

identifiers

A

Identifiers can be used to name classes, variables, and subroutines. An identifier is a sequence of one or
more characters. It must begin with a letter or underscore and must consist entirely of letters,
digits, and underscores. No spaces are allowed in identifiers;

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

reserve words

A

words reserved for special uses in Java that can’t be used as identifiers, such as:
class, public, static, if, else, while, and several dozen other words

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

What character set does Java use?

A

Unicode

17
Q

compound names

A

which consist of several simple names separated by periods. (Compound names are also
called qualified names.) You’ve already seen an example: System.out.println. The idea
here is that things in Java can contain other things. A compound name is a kind of path to an
item through one or more levels of containment. The name System.out.println indicates that
something called “System” contains something called “out” which in turn contains something
called “println”.

18
Q

variable

A

a name used to refer to data stored into memory. Its a memory location of where the data is stored.

19
Q

strongly typed

A

means that Java strictly enforces holding the data type it was designed for and doesn’t allow you to change it.

20
Q

primitive types

A

The primitive types are named
byte, short, int, long, float, double, char, and boolean. The first four types hold integers
(whole numbers such as 17, -38477, and 0). The four integer types are distinguished by the
ranges of integers they can hold.

21
Q

float and double

A

types hold real numbers (such as 3.6 and

-145.99). Again, the two real types are distinguished by their range and accuracy.

22
Q

char

A

holds a single character from the Unicode character set.

23
Q

boolean

A

holds the logical values of true or false

24
Q

byte

A

a variable type that holds 8 bits, which can represent any of the integers between -128 and 127, inclusive.

25
Q

short

A

corresponds to two bytes (16 bits). Variables of type short have values in the range
-32768 to 32767.

26
Q

int

A

corresponds to four bytes (32 bits). Variables of type int have values in the range
-2147483648 to 2147483647.

27
Q

long

A

corresponds to eight bytes (64 bits). Variables of type long have values in the range
-9223372036854775808 to 9223372036854775807.

28
Q

double

A

takes up 8 bytes, can range up to about 10 to the power 308, and has about
15 significant digits. Ordinarily, you should stick to the double type for real values.

29
Q

literals

A

constant values used in variables. Example of declaring a literal is ch = ‘A’; The single quote marks are used to declare constants

30
Q

tab

A

‘\t’ , using the escape character

31
Q

carriage return

A

‘\r’

32
Q

linefeed

A

‘\n’

33
Q

backslash

A

’\’

34
Q

How to express powers of 10?

A

“e12” and “e-108” represent powers of 10, so that

1.3e12 means 1.3 times 1012 and 12.3737e-108 means 12.3737 times 10−108.