JAVA Chapter 2, Ch 5 Multiple Choice and True/False, Java chapter 3-4 Test

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

True or False: It is not necessary to initialize accumulator variables

False

True or False: One limitation of the for loop is that only one variable may be initialized in the initialization expression.

False

True or False: The do-while is a pretest loop

False

True or False: The for loop is a posttest loop

False

True or False: To calculate the total number of iterations of a nested loop, add the number of iterations of all the loops.

False

if

Two important style rules for __ statements: the conditionally executed statement should appear on the line after and be indented one level from the if statement

Disadvantages

Two particular __________ of if-else statements: complex code and too much indenting causes statements to be off screen

//

Used to begin a single line comment.

{ ...}

Used to begin and end a set of related statements.

class

Used to declare a class.

/** */

Used to enclose documentation comments.

/* */

Used to enclose single or multiline comment.

Infinity

When a floating-point value is divided by zero the special value ______ is produced as the result of the division.

method

is a group of reusable programming statements that has been given a name.

Boolean expression

is only either true or false; appears inside of the parentheses of an 'if' statement setting the condition to execute

inheritance

is the ability to create new classes from an existing class

Polymorphism

is the idea that we can refer to pbjects of different but related types in the same way.

void

Indicates a method will not return any value.

0

A Java program crashes when it divides and integer by __.

flag

A boolean variable that signals when some condition exists in the program; true variable means condition does exist

static

A declaration use for class methods.

Package

A group of related classes. Also called a library.

Unicode

A international encoding system using sets of numbers that represents all letters, numbers, punctuation, and special characters of all the world alphabets

Object

A name to entry that consists of related data and instructions for performing actions on that data.

Java application

A package with a controlling class and possibly other classes.

Platform -- Independent Application

A program that can be run on any computer regardless of operating system or hardware configuration.

String

A set of characters.

Code conventions

A set of guidelines for writing an application.

Algorithm

A set of steps that outline how to solve a problem.

Bytecode

Compiled Java source code.

Logical operators

Connect two or more relational expressions into one or reverse the logic of an expression: &&, ||, !

Syntax Error

A statement that violates the rules of Java.

Object oriented programming (OOP)

A systematic, modular approach to developing complex programs.

Decision structure

Allows a program to execute some statements only under certain circumstances

public

An access modifier that declares a class or method as available to any code.

Pseudocode

An algorithms written in a mix of English and program code.

Statement

An instruction in a program.

Argument

Data passed to a method for processing.

Relational operator

Determines whether a specific relationship exists between two values: >, <, >=, <=, ==, !=

Null statement

Empty statement that does nothing

block

Enclosing a group of statements inside {braces} creates a _____ of statements; grouping multiple if statements

==

Equal to, relational operator

\\

Escape sequence for displaying a backslash.

\"

Escape sequence for displaying a double quotation Mark.

\n

Escape sequence for displaying a new line.

\t

Escape sequence for displaying a tab.

Trailing else

Last clause in a block of if-else-if statements, usually used to catch errors

format ()

Method that displays more precisely formatted output to the screen.

println()

Method that displays output to the screen and then moves the insertion point to the next line.

print()

Method that displays output to the screen.

Comment Block

Multiline comments that describe a program, class, or method.

!=

Not equal to, relational operator

Importable

Package code that can be used by an application.

encapsulation

Protecting an object's data from code outside the class.

;

Required at the end of each program statement.

Output Stream

Sends data to an output device, typically the computer screen.

Just -- in -- time compiler

Software that converts bytecode to specific machine code.

Interpreter

Software that runs each bytecode instruction of the compiled Java program.

if-else

Statement that executes either a block of statements for a true expression or executes a separate block of statements for a false expression

if-else-if

Statement that tests a series of conditions, often simpler than using nested if-else statements

Comment

Text that provides information to the reader of program code.

Java Virtual Machine

The Java bytecode interpreter.

Java.lang.System

The class that contains the out member.

Source code

The code type by a programmer.

Class

The description of an object. A collection of programming statements that specify the attributes and methods that a particular type of object can have

out

The java.lang.System member that represents the standard output stream.

main()

The method in the controlling class that is automatically executed when the Java application is run.

Machine code

The most basic computer language, which is comprised of just 0's and 1's.

Method

The name set of instructions that perform a single, well-defined task. A method is always a member of a class.

Compiling

The process where source code is converted to code the computer understands

Execution

To run a program.

nested

To test more than one condition and if statement can be ______ inside another if statement.

True or False: A variable may be defined in the initialization expression of the for loop.

True

True or False: In a nested loop, the inner loop goes through all of its iterations for every iteration of the outer loop.

True

True or False; The while loop is a pretest loop.

True

Sequence structure

When statements are executed in sequence without branching off in another direction

Escape Sequence

a backslash followed by a symbol that together represents a character.

What will the println statement in the following program segment display? int x = 5; System.out.println(x++); a. 5 b. 6 c. 0 d. None of these

a. 5

To open a file for writing, you use the following class. o PrintWriter o FileOpen o OutputFile o FileReader

a. PrintWriter

This expression is executed by the loop only once, regardless of the number of iterations. o Initialization expression o Test expression o Update expression o Pre-increment expression

a. initialization expression

This is a variable that controls the number of iterations performed by a loop a. loop control variable b. accumulator c. iteration register variable d. repetition meter

a. loop control variable

The for loop is this type of loop a. pretest b. posttest c. prefix d. postfix

a. pretest

The while loop is this type of loop a. pretest b. prefix c. posttest d. postfix

a. pretest

This is a special value that signals when there are no more items from a list of times to be processed. This value cannot be mistaken as an item from the list. o Sentinel o Flag o Signal o Accumulator

a. sentinel

Primitive data

are common values such as numbers and characters.

attributes

are the values that objects store internally representing its state.

operators

are used to perform operations on primitive +-*/.

What will the println statement in the following program segment display? int x = 5; System.out.println(++x); a. 5 b. 6 c. 0 d. None of these

b. 6

This class allows you to read a line from a file. o FileWriter o Scanner o InputFile o FileReader

b. Scanner

When a program is finished using a file, it should do this. o Erase the file o Close the file o Throw an exception o Reset the read position

b. close the file

This type of loop always executes at least once. a. While b. Do-while c. For d. Any of these

b. do-while

The do while loop is this type of loop a. pretest b. posttest c. prefix d. postfix

b. posttest

This type of loop has no way of ending and repeat until the program is interrupted a. indeterminate b. interminable c. infinite d. timeless

c. infinite

In the expression number++, the ++ operator is in what mode? a. prefix b. pretest c. postfix d. posttest

c. postfix

To open a file for reading, you use the following classes. o File and Writer o File out Output o File and Input o File and Scanner

d. File and Scanner

This class allows you to use the print and println methods to write data to a file. o File o FileReader o OutputFile o PrintWriter

d. PrintWriter

This is a variable that keeps a running total. o Sentinel o Sum o Total o Accumulator

d. accumulator

What is each repetition of a loop known as? a. cycle b. revolution c. orbit d. iteration

d. iteration

classes

define objects and are like the data type of the object.

Controlling class

the class in any application that contains the main() method.


संबंधित स्टडी सेट्स

Alternators/Generators/Magnetism

View Set

280 - module 2 multiple choice - fixed

View Set

Implement Microsoft VPN Services Part Two

View Set