True/False Comp Sci

¡Supera tus tareas y exámenes ahora con Quizwiz!

A Java program will not compile unless it contains the correct line numbers.

False

All Java statements end with semicolons.

False

An important style rule you should follow when writing if statements is to line up the conditionally executed statement with the if statement.

False

Assuming that pay has been declared a double, the following statement is valid. pay = 2,583.44;

False

Both character literals and string literals can be assigned to a char variable.

False

Class names and key words are examples of variables.

False

Colons are used to indicate the end of a Java statement.

False

Compiled byte code is also called source code.

False

In Java the variable named total is the same as the variable named Total.

False

In a for statement, the control variable can only be incremented.

False

In a switch statement, if two different values for the CaseExpression would result in the same code being executed, you must have two copies of the code, one after each CaseExpression.

False

In the for loop, the control variable cannot be initialized to a constant value and tested against a constant value.

False

In the method header the static method modifier means the method is available to code outside the class.

False

In the method header, the method modifier public means that the method belongs to the class, not a specific object.

False

Java is a case-insensitive language.

False

Java source files end with the .class extension.

False

Only constants and variables may be passed as arguments to methods.

False

Programs never need more than one path of execution.

False

The contents of a variable cannot be changed while the program is running.

False

The do-while loop is a pre-test loop.

False

When testing for character values, the switch statement does not test for the case of the character.

False

When the break statement is encountered in a loop, all the statements in the body of the loop that appear after it are ignored, and the loop prepares for the next iteration.

False

When two Strings are compared using the compareTo method, the cases of the two strings are not considered.

False

A file must always be opened before using it and closed when the program is finished using it.

True

A local variable's scope always ends at the closing brace of the block of code in which it is declared.

True

A parameter variable's scope is the method in which the parameter is declared.

True

A value-returning method can return a reference to a non-primitive type.

True

A variable's scope is the part of the program that has access to the variable.

True

Although the dollar sign is a legal identifier character, you should not use it because it is normally used for special purposes.

True

An important style rule you should adopt for writing if statements is to write the conditionally executed statement on the line after the if statement.

True

Any method that calls a method with a throws clause in its header must either handle the potential exception or have the same throws clause.

True

Application software refers to programs that make the computer useful to the user.

True

Because the && operator performs short-circuit evaluation, your boolean expression will usually execute faster if the subexpression that is most likely false is on the left of the && operator.

True

Because the || operator performs short-circuit evaluation, your boolean expression will generally be evaluated faster if the subexpression that is most likely to be true is on the left.

True

Constants, variables, and the values of expressions may be passed as arguments to a method.

True

Each byte is assigned a unique number known as an address.

True

Encapsulation refers to the combining of data and code into a single object.

True

If the compiler encounters a statement that uses a variable before the variable is declared, an error will result.

True

In a switch statement, each of the case values must be unique.

True

Java provides a set of simple unary operators designed just for incrementing and decrementing variables.

True

Logical errors are mistakes that cause the program to produce erroneous results.

True

Methods are commonly used to break a problem into small manageable pieces.

True

Named constants are initialized with a value, that value cannot be changed during the execution of the program.

True

No statement outside the method in which a parameter variable is declared can access the parameter by its name.

True

Programming style includes techniques for consistently putting spaces and indentation in a program so visual cues are created.

True

The Java Virtual Machine is a program that reads Java byte code instructions and executes them as they are read.

True

The String.format method works exactly like the System.out.printf method, except that it does not display the formatted string on the screen.

True

The System.out.printf method formats a string and displays it in the console window.

True

The computer is a tool used by so many professions that it cannot be easily categorized.

True

The do-while loop must be terminated with a semicolon.

True

The expression in a return statement can be any expression that has a value.

True

The if/else statement will execute one group of statements if its boolean expression is true or another group if its boolean expression is false.

True

The while loop has two important parts: (1) a boolean expression that is tested for a true or false value, and (2) a statement or block of statements that is repeated as long as the expression is true.

True

Two general categories of methods are void methods and value returning methods.

True

Unicode is an international encoding system that is extensive enough to represent ALL the characters of ALL the world's alphabets.

True

When an object's internal data is hidden from outside code and access to that data is restricted to the object's methods, the data is protected from accidental corruption.

True

When the continue statement is encountered in a loop, all the statements in the body of the loop that appear after it are ignored, and the loop prepares for the next iteration.

True

When you open a file with the PrintWriter class, the class can potentially throw an IOException.

True

When you pass the name of a file to the PrintWriter constructor, and the file already exists, it will be erased and a new empty file with the same name will be created.

True

Without programmers, the users of computers would have no software, and without software, computers would not be able to do anything.

True

You can use the PrintWriter class to open a file for writing and write data to it.

True

You must have a return statement in a value-returning method.

True


Conjuntos de estudio relacionados

Ch 10 Fiscal Responsibility and Budgeting

View Set

SECURITY + WIRELESS DEFENSES 5.12

View Set

11-Powers of Congress Flash Cards

View Set