Chapter 1 – Getting Started Flashcards

1
Q

intermediate language

A

An intermediate language is an abstract programming language used by a compiler as an in-between step when translating a computer program into machine code. Before compiling the program into code for an actual, physical machine, the compiler first translates it into intermediate code suitable for a theoretical, abstract machine. This code is analyzed by the compiler, and if any opportunities for optimization are identified the compiler can perform the optimizations when making the translation into assembly language.

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

Java byte-code (aka byte-code)

A

An intermediate language that Java code is translated into. Java bytecode is the instruction set of the Java virtual machine (JVM).

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

code

A

A program or a part of a program.

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

object-oriented programming (OOP)

A

OOP is a programming methodology that views a program as consisting of objects that interact with each other by means of actions.

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

object

A

An object can be a variable, a data structure, a function, or a method, and as such, is a value in memory referenced by an identifier.

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

method

A

Actions that an object can take are called the methods of that object.

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

class

A

Objects of the same kind or that have the same type. For example, all of the airplanes in a flight simulation game might be of the same class, but they are different instances of that class.

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

application program

A

A class with a method named main; when you run the Java program, the run-time system automatically invokes the method named main (that is, it automatically initiates the main action).

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

applet

A

A little Java application, applets and applications are almost identical. The difference is that applications are meant to be run on your computer like any other program, whereas an applet is meant to be run from a Web browser, and so can be sent to another location on the Internet and run there. Applets always use a windowing interface, but not all programs with a windowing interface are applets.

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

application

A

An application, or application program, is just a regular program. That is, computer software designed to help the user to perform specific tasks.

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

applet viewer

A

Although applets are designed to be run via a Web browser, they can also be run via this thing, which is typically meant to be for debugging purposes.

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

System.out.println

A

A method in the System.out framework that prints the text in its argument with a new line character (“\n”) attached at the end.

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

invoking

A

hen an object performs an action using a method, it is called invoking (or calling) the method.

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

dot

A

In a Java program, you write such a method invocation by writing the object followed by a dot (period), followed by the method name, and some parentheses that may or may not have something inside them.

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

argument

A

The thing (or things) inside the parentheses is called an argument(s), which provides information needed by the method to carry out its action.

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

sending a message

A

Another term for invoking a method is to send a message to the object. With this view, a message is sent to the object (by invoking a method) and in response, the object performs some action (namely, the action taken by the method invoked).

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

variable int

A

A variable declaration that contains only integers. So for example, the following code declares the variable var and says that it can only take integer values (say 2, or -7):
> int var;

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

equal sign / assignment operator

A

The equal sign (=) is used in Java as the assignment operator. This operator assigns the value to its right to the variable on its left. For example, the following will declare var as a variable integer and assign 7 - 9 to it:
> int var = 7 - 9;

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

high-level, low-level, and machine languages

A

A high-level programming language is a language designed to be (relatively) easy for people to write and understand. Machine languages are the languages that computers can directly understand. Machine languages and things like them are called low-level languages.

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

compiler

A

A compiler is a program that translates a high-level language program, such as a Java program, into an equivalent low-level-language program.

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

Java Virtual Machine (JVM)

A

Bytecode is not the machine language for any particular computer; it is the machine language for a fictitious computer called the Java Virtual Machine (JVM). A Java virtual machine (JVM) is (also) a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode.

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

interpreter

A

One of the ways to implement the JVM, an interpreter combines the translation of the bytecode and the execution of the corresponding machine language instructions. The interpreter works by translating an instruction of bytecode into instructions expressed in your computer’s machine language and then executing those instructions on your computer. It does this one bytecode instruction at a time. Thus, an interpreter translates and executes the instructions in the bytecode one after the other, rather than translating the entire bytecode program at once.

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

Just-In-Time (JIT)

A

Modern implementations of the JVM use a JIT compiler, which uses a combination of interpretation and compilation. The JIT compiler reads the bytecode in chunks and compiles entire chunks to native machine language instructions as needed. The compiled machine language instructions are remembered—that is, cached—for future use, so the chunk needs to be compiled only once. This model generally runs programs faster than the interpreted model, which always has to translate the next bytecode instruction to machine code instructions.

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

run command

A

A command that executes the JVM on the bytecode.

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

source code

A

The original code before it is compiled into bytecode.

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

object code

A

The bytecode (or really any intermediate language code) generated by a compiler.

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

.java files

A

These are files that hold the source code which will be compiled into object code.

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

javac

A
This is a command that compiles its argument from a .java file (source code) to a .class file (object code). For example:
> javac program.java
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

.class files

A

When you compile a Java class, the resulting bytecode for that class is placed in a .class file of the same name, except that the ending is changed from .java to .class. So, files when you compile a class named FirstProgram in the file FirstProgram.java, the resulting bytecode is stored in a file named FirstProgram.class.

30
Q

bug

A

A mistake in a program is called a bug.

31
Q

debugging

A

The process of eliminating mistakes in your program.

32
Q

syntax error

A

A syntax error is a grammatical mistake in your program; that is, a mistake in the allowed arrangement of words and punctuations. If you violate one of these rules—for example, by omitting a required punctuation—it is a syntax error. The compiler will catch syntax errors and output an error message telling you that it has found the error, where it thinks the error is, and what it thinks the error is. If the compiler says you have a syntax error, you undoubtedly do. However, the compiler could be incorrect about where and what the error is.

33
Q

run-time error

A

An error that is not detected until your program is run is called a run-time error. If the computer detects a run-time error when your program is run, then it will output an error message. The error message may not be easy to understand, but at least it lets you know that something is wrong.

34
Q

logic error

A

A mistake in the underlying algorithm for your program is called a logic error. If your program has only logic errors, it will compile and run without any error message. You have written a valid Java program, but you have not written a program that does what you want. The program runs and gives output, but the output is incorrect.

35
Q

identifier

A

The name of a variable (or other item you might define in a program).

36
Q

case-sensitive

A

Java is a case-sensitive language; that is, it distinguishes between upper- and lowercase letters in the spelling of identifiers.

37
Q

keyword (aka reserved words)

A

There is a special class of identifiers, called keywords or reserved words, that have a predefined meaning in Java and that you cannot use as names for variables or anything else.

38
Q

declare

A

Every variable in a Java program must be declared before it is used. When you declare a variable, you are telling the compiler—and, ultimately, the computer—what kind of data you will be storing in the variable.

39
Q

floating-point number

A

A number that has a decimal point. Decimals are represented with the double type in Java.

40
Q

primitive types

A

Java has basic types for characters, different kinds of integers, and different kinds of floating-point numbers (numbers with a decimal point), as well as a type for the values true and false. These basic types are known as primitive types. Here’s all of them: boolean, char, byte, short, int, long, float, double.

41
Q

assignment statement

A

The most direct way to change the value of a variable. This kind of statement has the following form:
> = ;
where is a literal that is interpreted appropriately for the type of .

42
Q

uninitialized variable

A

A variable that has been declared but that has not yet been given a value by some means, such as an assignment statement, is said to be uninitialized. For example:
> int variable;

43
Q

assigning int values to double variables

A

There are some special cases where it is permitted to assign a value of one type to a variable of another type. It is acceptable to assign a value of an integer type, such as int, to a variable of a floating-point type, such as the type double.

44
Q

integers and booleans

A

In many languages other than Java, you can assign integers to variables of type boolean and assign boolean values to integer variables. You cannot do that in Java. In Java, the boolean values true and false are not integers nor will they be automatically converted to integers. (In fact, it is not even legal to do an explicit type cast from the type boolean to the type int or vice versa. Explicit type casts are discussed later in this chapter in the subsection “Type Casting.”)

45
Q

constants (or literals)

A

Constants are things that don’t change in value. For example, 2.5. A literal is essentially a constant as it is written in the program. For example, “2.5” is a literal in the expression:
> double variable = 2.5;

46
Q

e notation

A

A more complicated notation for floating-point constants, such as constants of type double, is called scientific notation or floating-point notation and is particularly handy for writing very large numbers and very small fractions. For instance, in Java, we represent 2.5 * 10^5 as:
> double variable = 2.5e5;

47
Q

quotes and literal Strings, chars

A

In Java, a literal String expression contains the string in double quotes. For example:
>String myString = “bob”;
On the contrary, the char type has its literal in single quotes:
>char myChar = ‘b’;

48
Q

mixing types (e.g., what happens when you do x + y when x is an int and y is a double?)

A

In Java, some types can be mixed during arithmetic operations. The type that an arithmetic operation results in is the rightmost type in the expression as it appears in this list:
byte, short, int, long, float, double.
For example, if an int is added to a float, you will get a float.

49
Q

integer division

A

When used with two operands of type int, the division operator yields the integer part resulting from division. In other words, integer division discards the part after the decimal point. So, 10/3 is 3.

50
Q

the % operator

A

The operator % can be used with operands of type int to recover the information lost when you use / to do division with numbers of type int. x % y gives you the remainder of x / y.

51
Q

type coercion

A

An automatic, or implicit, type cast. For example, in the following code, “5” is an int that is typecasted to “5.0,” a double:
> double d = 5;

52
Q

v++ versus ++v

A

Notice that the two increment operators n++ and ++n have the exact same effect on a variable n: They both increase the value of n by one. But the two expressions evaluate to different values. Remember, if the ++ is before the variable, then the incrementing is done before the value is returned; if the ++ is after the variable, then the incrementing is done after the value is returned.

53
Q

decrement operator

A

Both n−− and −−n change the value of n by subtracting one, but they evaluate to different values. n−− evaluates to the value n had before it was decremented; on the other hand, −−n evaluates to the value n has after it is decremented.

54
Q

String

A

There is no primitive type for strings in Java. However, there is a class called String that can be used to store and process strings of characters. This section introduces the class String.

55
Q

+ operator (w/ strings)

A

When you use the + operator on two strings, the result is the string obtained by connecting the two strings to get a longer string.

56
Q

concatenation

A

The string obtained by connecting the two strings to get a longer string. To concatenate s1 and s2 in Java, do:
> s1 + s2;

57
Q

method call or method invocation

A
Classes are central to Java, and you will soon be defining and using your own classes. A class is the name for a type whose values are objects. Objects are entities that store data and can take actions. For example, objects of the class String store data consisting of strings of characters, such as "Hello". The actions that an object can take are called methods. So to call the method length() on a string, do the following (Dot notation):
> "Hello".length();
58
Q

calling object

A

The object before the dot is known as the calling object in method invocation. In the following example, the string s:
> String s = “Hello”;
> s.length();

59
Q

position

A

Some methods for the class String depend on counting positions in the string. Positions are counted starting with 0, not with 1. So, in the string “Surf time”, ‘S’ is in position 0, ‘u’ is in position 1, and so forth.

60
Q

index

A

A position is usually referred to as an index. So, it would be preferable to say: ‘S’ is at index 0, ‘u’ is at index 1, and so on.

61
Q

backslash \

A

A backslash, \, preceding a character tells the compiler that the character following the \ does not have its usual meaning.

62
Q

escape sequence

A

A sequence of characters that starts with a backslash \ is called an escape sequence or an escape character. The sequence is typed in as two characters with no space between the symbols. Several escape sequences are defined in Java.
" Double quote.
' Single quote.
\ Backslash.
\n New line. Go to the beginning of the next line.
\r Carriage return. Go to the beginning of the current line. \t Tab. White space up to the next tab stop.

63
Q

What does it mean to say that strings in Java are immutable objects?

A

In Java, an object of type String is an immutable object, meaning that the characters in the String object cannot be changed.

64
Q

ASCII

A

The ASCII character set is simply a list of all the characters normally used on an English-language keyboard plus a few special characters. In this list, each character has been assigned a number so that characters can be stored by storing the corresponding number.

65
Q

Unicode

A

The Unicode character set includes the ASCII character set plus many of the characters used in languages with a different alphabet from English.

66
Q

//comments

A

All of the text between the // and the end of the line is a comment. The compiler simply ignores anything that follows // on a line.

67
Q

line comments

A

The symbols // are two slashes (without a space between them). Comments indicated with // are often called line comments or inline comments.

68
Q

/comments/

A

There is another way to insert comments in a Java program. Anything between the symbol pair /* and the symbol pair / is considered a comment and is ignored by the compiler. Unlike the // comments, which require an additional // on each line, the / to */ comments can span several lines.

69
Q

block comments

A

Comments of the /* */ type are often called block comments.

70
Q

when to comment

A

It is difficult to say just how many comments a program should contain. The only correct answer is “just enough,” which of course conveys little to the novice programmer. It will take some experience to get a feel for when it is best to include a comment. Whenever something is important and not obvious, it merits a comment. However, providing too many comments is as bad as providing too few. A program that has a comment on each line is so buried in comments that the structure of the program is hidden in a sea of obvious observations.

71
Q

self-documenting

A

A well-written program is called self-documenting, which means that the structure of the program is clear from the choice of identifier names and the indenting pattern. A completely self-documenting program would need none of these // comments that are only for the programmer who reads or modifies the code. That may be an ideal that is not always realizable, but if your code is full of // comments and you follow our convention on when to use them, then either you simply have too many comments or your code is poorly designed.

72
Q

class loader

A

A Java program is divided into smaller parts called classes, and normally each class definition is in a separate file and is compiled separately. In order to run your program, the bytecode for these various classes needs to be connected together. The connecting is done by a program known as the class loader.