AP CompSci

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

Assume that A is true and B is false. Write the values of the following expression:

!(A || B)

List the logical operators in the order in which each one would be evaluated at run time.

!,&&, ||

Write the integer values of red, green, and blue for the color black.

0,0,0

Write the integer values of red, green, and blue for the color high intensity blue.

0,0,255

Write the integer values of red, green, and blue for the color medium gray.

127,127,127

Write the integer values of red, green, and blue for the color white.

255,255,255

Assume that A is true and B is false. Write the values of the following expression:

A && !B

Assume that A is true and B is false. Write the values of the following expression:

A && B

What is a Scanner object?

A Scanner object receives messages to input data from a human user. For example, when sent the message nextDouble, a Scanner object causes a program to wait for a user to enter the digits of a number. When the user presses the Enter key, the object returns the corresponding floating-point number.

Find the compile-time errors in the following statement: System.out.println("Here is an error);

A double quote mark before the right parenthesis is missing.

Interface

A list of the methods supported by the server. This is what the client needs to know.

Nested loop

A loop as one of the statements in the body of another loop. (252)

Truth table

A means of listing all of the possible values of a Boolean expression. (230)

Reliability

A measure of software quality where the software works as intended. (253)

Constructor

A method that creates a new instance of a class. (Default constructor has no parameters.)

Mutator

A method used to change the value of an attribute of an object.

Accessor

A method used to examine an attribute of an object without changing it.

Helper method

A method used within the implementation of a class but not used by clients of that class.

Combinatorial explosion

A multiplicative growth. (255)

Formal parameter

A name, introduced in a method definition, which is replaced by an actual parameter when the method is called.

What is the difference between a nested if statement and a multiway if statement?

A nested if statement contains an if statement in the action that follows the condition. A multiway if statement contains an if statement in the action that follows the else.

Substring

A piece of a string, including characters between space characters. (265)

What is a portable program?

A portable program can be written once and recompiled to run on any machine

Give a short definition of "program."

A program is a sequence of instructions and data that solves a problem or accomplishes a task.

Why is readability a desirable characteristics of a program?

A readable program is more easily understood and modified by others, even by its original author.

Find the compile-time errors in the following statement: System.out.println("Here is another error";

A right parenthesis before the semicolon is missing.

What is a robust program? Give an example.

A robust program is one that responds gracefully to invalid data. An example is a program that prints an error message when a negative number is entered for the number of hours worked.

Nested if statement

A selection statement used within another selection statement. (245)

Complete code coverage

A set of tests in which every line in a program is executed at least once. (242)

Arithmetic overflow

A situation that arises when the computer's memory cannot represent the number resulting from an arithmetic operation. (258)

Output assertion

A statement of what is expected to be true after a loop is exited. (259)

Input assertion

A statement of what is expected to be true before a loop is entered. (259)

Visibility modifier

A symbol (public or private) that specifies the kind of access that clients have to a class's data and methods.

What is a thread? Describe how threads might be used in a program.

A thread is a process that can run concurrently with other processes. One program can consist of several threads. In a given program, one thread might be loading an image while another thread takes input from the user.

Boundary condition

A value at which two equivalence classes meet. (242)

What is a variable in a program and how is it used?

A variable is a name of a storage location in computer memory. Programs can store values, such as numbers or references to objects, in variables and use these values whenever they are needed. In general, a variable provides a convenient way of remembering a value that might be modified during the course of a program.

Explain the difference between a variable of type double and a variable of type Scanner.

A variable of type double names a storage location for a floating-point number. A variable of type Scanner names a storage location for a reference to a Scanner object.

Actual parameter

A variable or expression contained in a method call and passed to that method.

Assume that A is true and B is false. Write the values of the following expression:

A || B

Equivalence class

All the sets of test data that exercise a program in the same manner. (242)

What is an applet? Describe how applets are used.

An applet is a Java program that runs in a Web browser. The user launches an applet by selecting a hot spot in a Web page. The hot spot asks the Web page's server to transmit the applet's byte code to the client's Web browser. The byte code is checked for security, and then the Web browser's JVM executes the code.

Loop invariant

An assertion that expresses a relationship among variables that remains constant on all iterations of a loop. (260)

Loop variant

An assertion whose truth changes between the first and final execution of a loop. (261)

What are boundary conditions? Give an example.

Boundary conditions are test data that are at or near the limits of a program's valid data. For example, the data 0, 1, 39, and 40 are the boundary conditions of a program that computes a weekly pay based on 40 or fewer hours per week.

What is byte code? Describe how the JVM uses byte code.

Byte code is the code to which a Java source program translates during compilation. The JVM executes the byte code by interpreting its instructions.

What are compile-time errors?

Compile-time errors occur while a program is being

__________ means that every line of code in a program has been executed at least once.

Complete code coverage

What happens when we provide complete code coverage of a program?

Complete code coverage provides a test of all of the possible branches in the control statements of a program.

Extreme condition

Data at the limits of validity. (243)

Reference types

Data types such as String, Student, Scanner. Amount of memory is dependent on size of object being used.

Primitive types

Data types such as int, double, boolean. Amount of memory needed is fized.

Logical operator

Either logical connective (&&, ||) or negation (!). (225)

What is an equivalence class? Give an example.

Equivalence classes are sets of test data that execute a program's instructions in the same manner. For example, the datum 30 belongs to the equivalence class of a program that computes a weekly pay based on 40 or fewer hours per week.

What are extreme conditions? Give an example.

Extreme conditions are test data that are invalid and might cause strange behavior if not detected and handled properly. For example, the data -1 and 41 are among the extreme conditions of a program that computes a weekly pay based on 40 or fewer hours per week.

True or False? Most loops execute a fixed number of times.

False. Most loops execute 0, 1, or more than one time depending on inputs.

Superclass

In the heirarchy of class structure, it is above another class.

Subclass

In the heirarchy of class structure, it is below a class.

What does JVM stand for?

JVM stands for Java virtual machine.

Describe two features of Java that make it a better language than C++.

Java has standard features for writing programs with graphical user interfaces and writing network-based applications.

Extended if statement

Nested selection where additional if-else statements are used in the else option. (248)

Write a code segment that would be used to set the layout for adding panels to a 5-by-5 grid in a window. You may assume that the panel's content pane is named pane.

Pane.setLayout(new GridLayout(5, 5));

Where are panels displayed when a border layout is used to control their placement in a window?

Panels can be displayed in any of the five regions under the influence of a border layout - labeled north, south, east, west, and center.

What would reasonable test data for a loop that does not execute a fixed number of times?

Reasonable test data for a loop that does not execute a fixed number of times would be a datum that causes the loop not to execute at all, a datum that causes one pass through the loop, and a datum that causes multiple passes through the loop.

Object

Runtime entity that contains data and responds to messages.

A(n) __________ object can be used to read words from a string.

Scanner

Class

Software package or template that describes the characteristics of similar objects.

Write a sequence of statements to display your name, address, and phone number in the terminal window.

System.out.println("Rosalie Marquez"); System.out.println("231 Mayberry Lane"); System.out.println("Montvale, CA 33422"); System.out.println("(506)-445-6677");

(T or F) Objects are values of reference types.

T

True or False? A loop's invariant expresses a constant relationship among variables during the execution of a loop.

TRUE

True or False? A nested if statement can be converted to an equivalent if statement whose Boolean expression uses the && operator.

TRUE

True or False? Extreme conditions involve data at the limits of validity.

TRUE

Describe the role of the assignment (=) operator in a program.

The assignment operator causes a value to be stored in a variable.

Encapsulation

The combining of data and behavior into a single software package.

Describe the roles and responsibilities of a frame, a panel, and a layout manager in a GUI application.

The frame plays the role of the main window in an application. Its responsibilities are to display controls for resizing, zooming, minimizing, and closing the window. A panel plays the role of a rectangular area within a window on which shapes or images can be painted. A panel is responsible for setting its background color and refreshing itself when needed. A layout manager plays the role of the organizer of components within a container. Its responsibility is to influence the placement of a component in a container.

Scope

The largest area of program text in which an identifier is available.

What is the effect of the message println?

The message println causes the object to which it is sent to run the corresponding method. This method displays the message's parameter, a string or a number, on the terminal screen.

Quality assurance

The ongoing process of making sure that a software product is developed to the highest standards possible, subject to the constraints of time and money. (242)

Lifetime

The period during which a variable can be used.

Instantiation

The process of creating a new object.

Suppose a teacher uses grades from 0 to 100 and wants to discount all grades below 60 in her records. Discuss the equivalence classes, boundary conditions, and extreme conditions used to test a program that processes this information.

The program has two equivalence classes consisting of data ranging from 0 to 59 and from 60 to 100. The boundary conditions are 0, 1, 58, 59, 60, 61, 99, and 100. Extreme conditions are -1 and 101.

Identity

The property of an object that it is the same thing at different points in time, even though the values of its attributes might change.

Server

The receiver of a message.

Client

The sender of a message.

Behavior

The set of actions that a class of objects supports.

State

The set of all the values of the variables of a program at any point during its execution.

Robust

The state in which a program is protected against most possible crashes from bad data and unexpected values. (236)

Describe how to use the System.out object.

This name refers to an object that can be sent the message println.

Name the three steps in writing and running a program.

Three steps in writing and running a program are editing, compilation, and execution.

null

Value of a reference object when it hasn't been instantiated.

An input assertion states what is true __________ executing a loop.

before

An object has __________ as defined by the methods of its class.

behavior

One of the most common programming mistakes involves forgotten or misplaced __________.

braces

A blueprint for a set of objects is a(n) __________.

class

A(n) __________ contains code that is run to initialize data when an object is instantiated.

constructor

Most errors that occur in nested if statements are __________ errors.

logic

A nested loop is contained in another __________.

loop

Construct a Boolean expression that tests whether the value of variable x is within the range specified by the variables min (smallest) and max (largest).

min < x && max > x or x >= min && x <= max

Describe the difference between print and println and give an appropriate example of the use of each.

print displays a string without a newline character, whereas println adds a newline character to the display. Here is an example of their use:

The __________ of an object is the set of values of its data.

state

Private and public are examples of __________.

visibility modifiers


Set pelajaran terkait

Chapter 5 Externalities, Environmental Policy, and Public Goods

View Set

missing Chapter 47: Assessment of Endocrine System

View Set

Varcarolis 8th Chapter 14: Depressive Disorders

View Set