CS 149 Chapter 2

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What is the value of trouble if you assign 1/4 to it? Write your answer with two decimal places (e.g., 1.23).

0.00

What is the value of 1 + 2 * 3 - 4 in Java?

3

expression

A combination of variables, operators, and values that represents a single value. Expressions also have types, as determined by their operators and operands.

floating-point

A data type that represents numbers with an integer part and a fractional part. In Java, the default floating-point type is double.

memory diagram

A graphical representation of the state of a program at a point in time.

variable

A named storage location for values. All variables have a type, which is declared when the variable is created.

value

A number, string, or other data that can be stored in a variable. Every value belongs to a type (for example, int of String).

keyword

A reserved word used by the compiler to analyze programs. You cannot use keywords (like public, class, and void) as variable names.

declaration

A statement that creates a new variable and specifies its type.

assignment

A statement that gives a value to a variable.

operator

A symbol that represents a computation like addition, multiplication, or string concatenation.

logic error

An error in a program that makes it doe something other than what the programmer intended.

run-time error

An error in a program that makes it impossible to run to completion. Also called an "exception".

compile-time error

An error in the source code that makes it impossible to compile. Also called a "syntax error".

Where else in the book (besides Chapter 2) can you find advice about syntax errors?

Appendix D

What is the value of "Hello" + 1 + 2 in Java?

Hello12

type

Mathematically speaking, a set of values. The type of a variable determines which values it can have.

operand

One of the values on which an operator operates. Most operators in Java require two operands.

What is the main problem with floating-point numbers?

Rounding errors lead to incorrect results.

rounding error

The difference between the number we want to represent and the nearest floating-point number.

order of operations

The rules that determine in what order expressions are evaluated. Also known as "operator precedence".

state

The variables in a program and their current values.

parse

To analyze the structure of a program; what the compiler does first.

initialize

To assign a variable for the first time.

concatenate

To join two values, often strings, end-to-end.

Which of the following statements may cause a run-time error? area = x + y; area = x / y; area = x - y; area = x * y;

area = x / y;

Write a Java statement that declares a variable named trouble with type double.

double trouble;

What is the main problem with this mathematical statement? 1 + 2 # 3 ~ its semantics ~ its solution ~ its style ~ its syntax

its syntax

When the compiler says "reached end of file while parsing", what is most likely the problem?

missing brace

What is the state diagram for the following assignments? (after the code runs) name = "Anna"; pin = 1234; year = 2000; pin = year;

name [Anna] pin [2000] year [2000]

Which of the following statements is a syntax error? ~ char c; ~ double d; ~ int i; ~ string s;

string s;

Why doesn't the following code compile? public static void main(String[] args) { x = 1.23; System.out.println(x + "/n"); }}

x has not been declared


Set pelajaran terkait

A Closer Look: Parallel Structure

View Set

Econ 202S Final Exam Review Part 3

View Set

IGCSE Chemistry - Extraction & Reactivity Series

View Set

Real estate settlement procedures act (RESPA)

View Set

DUAL ENROLLMENT ANATOMY MIDTERM!!!!

View Set

Modulo 6: Complejidad computacional

View Set

Accident and Sickness Policy Provisions, Clauses, and Riders

View Set

Ch 35 Assessment of the Immune System PrepU

View Set

ACC410 - Advanced Accounting - Test 2

View Set

Chapter 7: The Mole and Chemical Composition

View Set

Levels of organization, Circulatory System

View Set