Which of the following refers to a collection of programs that a computer executes?
- source code
- instructions
- assembler
- software
- Section Ref
- 1.1 Computer Programs
- Title
- Which (term) refers to a collection of programs?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-1
Computers are machines that __________________.
- design computer programs
- execute programs
- are imprecise and slow
- carry out a very narrow range of tasks
- Section Ref
- 1.1 Computer Programs
- Title
- What kind of machines are computers?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-2
Computer programming is ______________________.
- the act of designing and implementing a computer program
- the storage of data in the form of words and pictures
- the collection of peripheral devices connected to a computer
- the speed with which a computer operates
- Section Ref
- 1.1 Computer Programs
- Title
- What is computer programming?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-3
Consider the following statements regarding computers:
I. Computers can execute a large number of instructions in a fraction of a second.
II. Computer application areas mainly target the research and scientific communities.
III. The physical components of a computer constitute its hardware.
IV. Unlike humans, a computer never gets bored or exhausted when performing repetitive tasks.
Which of the statements are correct?
- I, III, and IV only
- I and III only
- III only
- I, II, and III only
- Section Ref
- 1.1 Computer Programs
- Title
- Which statement(s) regarding computers is (are) correct?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-4
Consider the following statements about computer programs:
I. Computer programs can be written by someone who has a basic knowledge of operating a computer.
II. Computer programs can complete complex tasks quickly.
III. Large and complex computer programs are generally written by a group of programmers.
IV. Computer programs are composed of extremely primitive operations.
Which of the statements are correct?
- I, II, III and IV
- I and IV
- II and III only
- II, III, and IV only
- Section Ref
- 1.1 Computer Programs
- Title
- Which statement(s) regarding computer programs is (are) correct?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-5
Writing a computer game in Java that has graphics, motion, and sound effects _______________________.
- cannot be done in the Java programming language
- is simple because of the power of Java
- requires a team of skilled programmers
- is more mundane than most programs
- Section Ref
- 1.1 Computer Programs
- Title
- What is required to write a computer game in Java?
- Difficulty
- easy
- id
- testbank-bjlo-2-ch01-6
The Central Processing Unit is primarily responsible for ______________.
- interconnecting computers that are separated by distance
- ensuring data persists when electrical power is turned off
- performing program control and data processing
- enabling a human user to interact with the computer
- Section Ref
- 1.2 The Anatomy of a Computer
- Title
- What is the function of a CPU?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-7
A single silicon chip made from potentially millions of transistors is called ______________.
- an Optical Disk (such as a DVD)
- secondary Storage
- a Hard Disk
- a Central Processing Unit (CPU)
- Section Ref
- 1.2 The Anatomy of a Computer
- Title
- What is a chip with transistors called?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-8
An example of an output device that interfaces between computers and humans is ____________.
- a speaker
- a mouse
- a microphone
- a keyboard
- Section Ref
- 1.2 The Anatomy of a Computer
- Title
- What is an example of an output device that interfaces between humans and computers?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-9
An example of an input device that interfaces between computers and humans is ____________.
- a monitor
- a microphone
- a printer
- a speaker
- Section Ref
- 1.2 The Anatomy of a Computer
- Title
- What is an example of an input device that interfaces between humans and computers?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-10
Programs that are not running are usually stored _____________________.
- in secondary storage
- on a backup device that is in a different physical location from the computer
- on the computer monitor
- in the CPU’s memory
- Section Ref
- 1.2 The Anatomy of a Computer
- Title
- Where are programs usually stored when they are not running?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-11
When a program begins to run, ___________________________.
- it is moved from the CPU’s memory to hard disk
- it is moved from DVD to hard disk
- it is moved to the CPU’s memory
- it must be connected to a computer network
- Section Ref
- 1.2 The Anatomy of a Computer
- Title
- What happens when a program begins to run?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-12
Which of the following typically provides data persistence without electricity?
I. The CPU’s memory
II. The hard disk
III. Secondary storage
- I, II, and III
- I and III only
- I and II only
- II and III only
- Section Ref
- 1.2 The Anatomy of a Computer
- Title
- Which storage type provides data persistence without electricity?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-13
In order for the ENIAC computer to be re-programmed, __________________________.
- vacuum tubes needed to be replaced
- wires needed to be plugged into a different wiring configuration
- the programmer needed to load the program from cards
- the programmer needed to download the new code over the computer network
- Section Ref
- 1.2 The Anatomy of a Computer
- Title
- What is true about the ENIAC being re-programmed?
- Difficulty
- easy
- id
- testbank-bjlo-2-ch01-14
Consider a scenario in which you develop a Java program on a computer that has a Pentium processor. What step should you take to run the same Java program on a computer that has a different processor?
- Load the program in a browser on the computer that has a different processor.
- The compiled Java machine language instructions can be run on any processor that has a Java Virtual Machine.
- You cannot run the program on a computer with a different processor because high-level programming languages are machine dependent.
- Develop the same program again on the computer that has a different processor and recompile the program.
- Section Ref
- 1.3 The Java Programming Language
- Title
- What step should you take to run a program in a high-level language on a (different) processor?
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-15
High-level programming languages _________________________.
- are made up primarily of ones and zeros
- are independent of the underlying hardware
- use syntax that is close to the underlying hardware’s instruction set
- are not standardized
- Section Ref
- 1.3 The Java Programming Language
- Title
- What are the characteristics of high-level programming languages?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-16
Which one of the following translates high-level descriptions into machine code?
- assembler
- compiler
- editor
- linker
- Section Ref
- 1.3 The Java Programming Language
- Title
- Which translates high-level descriptions into machine code?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-17
Computer scientists have devised __________________ that allow programmers to describe tasks in words that are closer to the syntax of the problems being solved.
- compilers
- embedded systems
- high-level programming languages
- machine instructions
- Section Ref
- 1.3 The Java Programming Language
- Title
- What are the tools used to describe and solve high-level problems?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-18
Small applications written in the Java programming language that can be located anywhere on the Internet are called __________.
- applets
- compilers
- embedded systems
- virtual machines
- Section Ref
- 1.3 The Java Programming Language
- Title
- What are small applications written in Java called?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-19
What is one of the benefits of using a high-level programming language like Java?
- Problems solved in a high-level language are independent of the underlying computer hardware.
- Statements in the high-level language are just like English.
- Its syntax is very similar to the hardware instruction set.
- No tools other than a text editor are required for programming.
- Section Ref
- 1.3 The Java Programming Language
- Title
- What are the benefits of using high-level languages?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-20
Because Java was designed for the Internet, which two of its attributes make it suitable for beginning programmers?
- Efficiency and security
- Safety and portability
- Safety and security
- Efficiency and portability
- Section Ref
- 1.3 The Java Programming Language
- Title
- What are two important Java attributes?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-21
In order to run Java programs on a computer, the computer needs to have software called a(n) __________.
- assembler
- virtual machine
- windows
- debugger
- Section Ref
- 1.3 The Java Programming Language
- Title
- Software needed to run Java on a computer
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-22
In order to translate a Java program to a class file, the computer needs to have software called a(n) _______________.
- assembler
- virtual machine
- compiler
- debugger
- Section Ref
- 1.3 The Java Programming Language
- Title
- Software needed to translate Java source code
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-23
A Java virtual machine is ____________.
- firmware
- hardware
- applet
- software
- Section Ref
- 1.3 The Java Programming Language
- Title
- A Java virtual machine is ___
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-24
The language developed by Sun Microsystems that became the Java programming language was originally designed to be simple, secure, and _______________.
- environmentally friendly, or "green"
- usable for many different processor types
- available over the Internet
- easy to program on a phone
- Section Ref
- 1.3 The Java Programming Language
- Title
- The Java programming language was designed to be _____?
- Difficulty
- easy
- id
- testbank-bjlo-2-ch01-25
The term applet refers to _________________.
- a Java program that runs as a C++ program
- any Java program
- a Java program that runs within a web browser
- a Java program that runs within an Integrated Development Environment (IDE)
- Section Ref
- 1.3 The Java Programming Language
- Title
- What is an "applet"?
- Difficulty
- easy
- id
- testbank-bjlo-2-ch01-26
Programmers have embraced Java over its closest rival, C++, mainly because _____________.
- it is easier to use
- it is easier to debug
- it is cheaper to use
- most computers only understand Java
- Section Ref
- 1.3 The Java Programming Language
- Title
- Why have programmers embraced Java?
- Difficulty
- easy
- id
- testbank-bjlo-2-ch01-27
How does Java achieve portability?
- Java programs are compiled to instructions for a virtual machine.
- Java programs must be re-compiled on each platform where they are to run.
- Java programs are interpreted.
- Java programs are compiled to instructions in the C++ programming language.
- Section Ref
- 1.3 The Java Programming Language
- Title
- How does Java achieve portability?
- Difficulty
- medium
- id
- testbank-bjlo-2-ch01-28
A Java Virtual Machine is _______________________.
- a theoretical machine to help understand the computational complexity of algorithms
- a kind of computer hardware that is embedded into the CPUs of all computers using Java
- a library package that extends the capability of the Java programming language
- a program that simulates a real CPU
- Section Ref
- 1.3 The Java Programming Language
- Title
- What is a Java Virtual Machine?
- Difficulty
- easy
- id
- testbank-bjlo-2-ch01-29
The Java programming language is itself relatively simple, but also contains a vast set of _______________.
- cross-platform scripting languages
- syntactical variations
- library packages
- program templates
- Section Ref
- 1.3 The Java Programming Language
- Title
- Java also contains a vast set of _____?
- Difficulty
- easy
- id
- testbank-bjlo-2-ch01-30
A Java class with the name Printer
has to be saved using the source file name:
-
Printer.txt
-
printer.txt
-
Printer.java
-
printer.java
- Section Ref
- 1.4 Becoming Familiar with Your Programming Environment
- Title
- Java source file names
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-31
An integrated development environment (IDE) bundles tools for programming into a unified application. What kinds of tools are usually included?
- a web browser
- source files and class files
- an editor and a compiler
- presentation tools
- Section Ref
- 1.4 Becoming Familiar with Your Programming Environment
- Title
- What kinds of tools are included in an IDE?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-32
What is the difference between an editor and a compiler?
- An editor allows program files to be written and stored; a compiler converts program files into an executable program.
- An editor converts program files into an executable program; a compiler allows program files to be written and stored.
- An editor allows program files to be written and stored; a compiler produces an indexed database of terms and keywords.
- An editor allows program files to be written and stored; a compiler produces an organized list of files.
- Section Ref
- 1.4 Becoming Familiar with Your Programming Environment
- Title
- What is the difference between an editor and a compiler?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-33
Suppose you examine a simple Java program and the first line is public class HelloPrinter
. Is this the same thing in Java as the line public class helloprinter
?
- No, because
helloprinter
is misspelled, the Java compiler will reject it.
- Yes, because these Java symbols both have the same letters, they are considered to be the same
- No, because Java is case-sensitive, these are considered to be completely distinct.
- Yes, because all Java symbols must have exactly twelve characters.
- Section Ref
- 1.4 Becoming Familiar with Your Programming Environment
- Title
- Are these lines of code the same?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-34
Consider the following statements about folders and your integrated development environment (IDE):
I. Hierarchical folders help to organize a project.
II. Folders are a way to visualize the layout of a file system.
III. Folders make it impossible to lose or accidentally delete a file.
Which statements are correct?
- I only
- III only
- I and II only
- I, II, and III
- Section Ref
- 1.4 Becoming Familiar with Your Programming Environment
- Title
- How is your integrated development environment organized?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-35
The source code for a Java program is stored in a file ________________.
- that ends with a
.class
suffix
- that can have any valid file name
- that has no suffix
- that ends with a
.java
suffix
- Section Ref
- 1.4 Becoming Familiar with Your Programming Environment
- Title
- Where is Java source code stored?
- Difficulty
- easy
- id
- testbank-bjlo-2-ch01-36
A Java "class" file _______________________.
- contains instructions for the Java virtual machine
- contains Java source code
- is the translation of the Java source code into C++
- is an internal file created by the Integrated Development Environment (IDE)
- Section Ref
- 1.4 Becoming Familiar with Your Programming Environment
- Title
- What is a Java "class" file?
- Difficulty
- easy
- id
- testbank-bjlo-2-ch01-37
Which of the following statements regarding backup strategies for Java files are true?
I. You should back up your projects often to prevent loss of valuable work.
II. You should check your backups only in case of loss of data.
III. You should pay attention to the backup direction.
- I and II only
- I, II, and III
- II and III only
- I and III only
- Section Ref
- 1.4 Becoming Familiar with Your Programming Environment
- Title
- Which statement regarding backup strategies for Java files is correct?
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-38
Which pointers about backing up your Java projects are important?
I. Check your backups once in a while.
II. Rely on the Java programming language's built-in back up system.
III. Back up often.
- I, II, and III
- I and II only
- II and III only
- I and III only
- Section Ref
- 1.4 Becoming Familiar with Your Programming Environment
- Title
- Which pointers are important for backing up Java projects?
- Difficulty
- easy
- id
- testbank-bjlo-2-ch01-39
Every Java program consists of one or more ___________.
- classes
- strings
-
System.out.println
statements
- values (arguments)
- Section Ref
- 1.5 Analyzing Your First Program
- Title
- What does every program consist of?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-40
Characters that are grouped together between double quotes (quotation marks) in Java are called _____________.
- syntax
- strings
- reserved words
- symbols
- Section Ref
- 1.5 Analyzing Your First Program
- Title
- What is the term for characters grouped together and enclosed in quotes?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-41
Every statement in Java must be terminated with ____________.
- the semi-colon character
;
-
System.out.println()
- a carriage return
- an escape sequence
- Section Ref
- 1.5 Analyzing Your First Program
- Title
- What does every statement end with?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-42
These two lines of code do not produce the same output. Why?
System.out.println(7 + 3);
System.out.println("7 + 3");
- The lack of escape characters causes the expressions to be treated differently.
- In fact, the two statements do produce the same output.
- The quotes cause the second expression to be treated as a string.
- Arithmetic calculations cannot take place within the
println
method call.
- Section Ref
- 1.5 Analyzing Your First Program
- Title
- Why do the example lines of code behave the way they do?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-43
What is the output from this code snippet?
System.out.print("The sum is ");
System.out.println("7 + 3");
- The sum is 21
- The sum is 4
- The sum is 10
- The sum is 7 + 3
- Section Ref
- 1.5 Analyzing Your First Program
- Title
- What is the output from this code?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-44
Which of the following symbols is used to terminate a Java program statement?
- colon
- single quote
- semicolon
- period
- Section Ref
- 1.5 Analyzing Your First Program
- Title
- Which symbol is used to terminate a Java program statement?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-45
Which of the following statements is valid with respect to the usage of a semicolon in Java?
- You cannot use a semicolon to terminate the
System.out.print
statement.
- A semicolon is used to terminate the
public class
statement.
- A semicolon is used to denote the end of a statement.
- You cannot put a semicolon within double quotation marks.
- Section Ref
- 1.5 Analyzing Your First Program
- Title
- Which statement is true about semicolon usage?
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-46
Which of the following statements is true with respect to the main
method in Java?
- A semicolon is required after the closing curly braces in the
main
method.
- Every Java application must have a
main
method.
- The opening and closing parentheses after the method name
main
are optional.
- A semicolon is required after the statement
public static void main()
- Section Ref
- 1.5 Analyzing Your First Program
- Title
- Which statement is true about the main method?
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-47
Which statement starts the declaration of a class in Java?
-
Java class
-
public class Classname
-
System.out.println("Hello, World!");
-
public static void main(String[] args)
- Section Ref
- 1.5 Analyzing Your First Program
- Title
- Which statement starts a class declaration in Java
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-48
Which Java statement prints a blank line?
-
System.out.println();
-
System.out.print();
-
public static void main(String[] args)
-
System.out.Println();
- Section Ref
- 1.5 Analyzing Your First Program
- Title
- Which statement prints a blank line
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-49
Which Java statement does not contain an error?
-
System.out.print(;
-
System.out.print()
-
System.out.printl();
-
System.out.println();
- Section Ref
- 1.5 Analyzing Your First Program
- Title
- Which statement does not contain an error
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-50
What is the output of the following code snippet?
System.out.print(4 + 4);
System.out.print(12);
- 4412
- 4 + 412
- 20
- 812
- Section Ref
- 1.5 Analyzing Your First Program
- Title
- What is output of snippet (using print)?
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-51
The Java statement public static void main(String[] args)
declares a ____________.
- class
- constant
- variable
- method
- Section Ref
- 1.5 Analyzing Your First Program
- Title
- The statement "public static void main(String[] args)"declares what?
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-52
Which of the following statements must you include in a Java class that can be executed by the virtual machine?
-
// Hello
-
System.out.println();
-
public static void main(String[] args)
-
return 0;
- Section Ref
- 1.5 Analyzing Your First Program
- Title
- Which statements should you include in executable class?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-53
What is the output of the following code snippet?
System.out.print("Hello");
System.out.println("Good Day!");
-
Hello
Good Day!
-
Hello Good Day!
-
HelloGood Day!
-
HelloGoodDay!
- Section Ref
- 1.5 Analyzing Your First Program
- Title
- What is output of snippet?
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-54
Which one of the following code snippets compiles without errors and displays the output “Hello Good Day!” on the screen?
-
System.out.print("Hello ")
System.out.println(Good Day!");
-
System.out.print("Hello );
System.out.println("Good Day!");
-
System.out.print("Hello");
System.out.println("Good Day!")
-
System.out.print("Hello ");
System.out.println("Good Day!");
- Section Ref
- 1.5 Analyzing Your First Program
- Title
- Which snippet compiles without errors and displays “Hello Good Day!”?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-55
What is the output of the following code snippet?
public class PrintIt
{
public static void main(String[] args)
{
System.out.println("4 * 4" + 12);
}
}
- 4 * 412
- 4412
- 1612
- 28
- Section Ref
- 1.5 Analyzing Your First Program
- Title
- What is output of snippet (with expressions)?
- Difficulty
- Hard
- id
- testbank-bjlo-2-ch01-56
Which statements are true?
I. In Java, a file can contain at most one public class.
II. The word public
denotes that the class is usable by the "public".
III. Every Java program must have a main
method.
- I, II, and III
- I and III only
- I and II only
- II and III only
- Section Ref
- 1.5 Analyzing Your First Program
- Title
- Which statements about Java are true?
- Difficulty
- medium
- id
- testbank-bjlo-2-ch01-57
The technical term for the values that a method needs in order to carry out its task is an argument. When there is more than one argument needed by a method, they are __________________.
- separated by semicolons
- separated by spaces
- separated by commas
- merged into a single variable
- Section Ref
- 1.5 Analyzing Your First Program
- Title
- Where a method needs more than one argument, they are ________?
- Difficulty
- easy
- id
- testbank-bjlo-2-ch01-58
In Java, if you want the compiler to interpret what you type as program instructions, you must __________________.
- write the instructions in all capital letters
- write correct Java statements separated by the semicolon
- enclose those instructions within quotation marks
- start the line that you type with the symbols
//
- Section Ref
- 1.5 Analyzing Your First Program
- Title
- How do you type program commands in Java?
- Difficulty
- easy
- id
- testbank-bjlo-2-ch01-59
What kind of error is it when your program has a syntax error?
- compile-time error
- logic error
- exception
- run-time error
- Section Ref
- 1.6 Errors
- Title
- Which kind of error is a syntax error?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-60
When a compiler finds a syntax error in a program, what happens?
- The compiler requests input from the user before it will continue.
- The compiler stops immediately.
- The compiler continues and may report about other errors but does not produce a Java class file.
- The compiler goes ahead and produces a Java class file, but leaves out the statement where there was an error.
- Section Ref
- 1.6 Errors
- Title
- What happens when the compiler finds a syntax error?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-61
What kind of error is created by the following code snippet?
System.outt.println("Hello");
- Logic error: the program will run until it comes to this statement
- Syntax error: the program will not compile
- No error: the code is correct
- Exception: the statement will generate an exception
- Section Ref
- 1.6 Errors
- Title
- What kind of error is created by the code snippet?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-62
What kind of error is created by the following code snippet?
System.out.print("The sum of 8 and 12 is ");
System.out.println(8 * 12);
- Exception: the statement will generate an exception
- Syntax error: the code will not compile
- No error: the code is correct
- Logic error: the program does not produce the desired result
- Section Ref
- 1.6 Errors
- Title
- What kind of error is created by the code snippet?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-63
What is a logic error?
- An error that occurs when a program is running because, for example, the wrong operator was used.
- An error introduced by the compiler when it guesses at how to fix a syntax error.
- An error in a statement that does not conform to the syntax of the programming language.
- An error in the hardware from overheating.
- Section Ref
- 1.6 Errors
- Title
- What is the definition of a logic error?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-64
How do programmers find exceptions and run-time errors?
- Re-compiling using different symbols
- Using the compiler
- Testing by running the program with a variety of input values
- Carefully reading over the program code
- Section Ref
- 1.6 Errors
- Title
- How do programmers find exceptions and run-time errors?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-65
The programmer, not the compiler, is responsible for testing a program to identify _________________.
- run-time errors
- undefined symbols
- syntax errors
- compile-time errors
- Section Ref
- 1.6 Errors
- Title
- Who is responsible for what (programmer vs. compiler)?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-66
Which one of the following errors represents a part of a program that is incorrect according to the rules of the programming language?
- run-time errors
- out-of-memory errors
- syntax errors
- logic errors
- Section Ref
- 1.6 Errors
- Title
- Which kind of error violates rules of the programming language?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-67
Who or what is responsible for inspecting and testing the program to guard against logic errors?
- end-user
- Integrated Development Environment
- compiler
- programmer
- Section Ref
- 1.6 Errors
- Title
- Who/what is responsible for ... guarding against logic errors?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-68
While developing a program, the programmer adds the discount amount to the total due instead of subtracting it. What type of an error is this?
- hardware error
- compile-time error
- logic error
- syntax error
- Section Ref
- 1.6 Errors
- Title
- What type of error is (adding instead of subtracting)?
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-69
In Java, the following statement ____________________.
System.out.print("hello");;;
- seems like it should print out "hello" but doesn't
- asks the user to enter a value and stores it in the variable "hello"
- is a syntax error
- is a legal statement
- Section Ref
- 1.6 Errors
- Title
- What can you say about the given Java statement?
- Difficulty
- medium
- id
- testbank-bjlo-2-ch01-70
Sometimes errors throw the compiler off track because __________________.
- the compiler must be trained by your programming style
- it cannot tell which language you are writing without a network connection
- the compiler does not understand quotation marks
- the compiler does not give up when it finds the first error
- Section Ref
- 1.6 Errors
- Title
- Why does the Java compiler sometimes get "off track"?
- Difficulty
- easy
- id
- testbank-bjlo-2-ch01-71
Some run-time errors are so severe that they generate ______________.
- the loss of your source code file
- an exception
- a syntax error
- an email to your account
- Section Ref
- 1.6 Errors
- Title
- Severe run-time errors generate _____?
- Difficulty
- easy
- id
- testbank-bjlo-2-ch01-72
During program development, errors are __________________.
- very rare
- automatically tracked by the Integrated Development Environment (IDE)
- unavoidable
- prevented by the Java virtual machine
- Section Ref
- 1.6 Errors
- Title
- What is true about errors during program development?
- Difficulty
- easy
- id
- testbank-bjlo-2-ch01-73
If you misspell a word in your Java program, which of the following statements are true?
I. the program will not compile
II. the program may compile, but not run
III. the program may compile and run but still have a logic error
- I, II, and III
- I and III only
- II and III only
- I and II only
- Section Ref
- 1.6 Errors
- Title
- What might happen if you misspell a word in your Java program?
- Difficulty
- medium
- id
- testbank-bjlo-2-ch01-74
A sequence of steps that is unambiguous, executable, and terminating is called _______________.
- an algorithm
- a logarithm
- a programming task
- pseudocode
- Section Ref
- 1.7 Problem Solving: Algorithm Design
- Title
- What is the term for a set of steps that is unambiguous, executable, and terminating?
- Difficulty
- easy
- id
- testbank-bjlo-2-ch01-75
You have been asked to develop an algorithm to calculate the total cost of a purchase order that contains several T shirts. The cost of each T shirt and the tax rate is known. The standard shipping charge for the entire order is $5.75, and the special delivery charge is $23.65. In addition, there is no tax on the shipping cost. Which of the following is the correct pseudocode for the required algorithm?
-
For each T shirt on the purchase order
Order cost = order cost + T shirt cost
Total purchase order cost = order cost + tax rate + 5.75
-
If standard shipping
Shipping cost = 5.75
Else
Shipping cost = 23.65
For each T shirt on the purchase order
Order cost = order cost + T shirt cost + shipping cost
Total purchase order cost = order cost * tax rate
-
If special delivery
Shipping cost = 5.75
Else
Shipping cost = 23.65
For each T shirt on the purchase order
Order cost = order cost + T shirt cost
Total purchase order cost = order cost * tax rate + shipping cost
-
For each T shirt on the purchase order
Order cost = order cost + T shirt cost
If standard shipping
Shipping cost = 5.75
Else
Shipping cost = 23.65
Total purchase order cost = order cost + order cost * tax rate + shipping cost
- Section Ref
- 1.7 Problem Solving: Algorithm Design
- Title
- Which is the correct pseudocode for algorithm to calculate total cost?
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-76
What is the purpose of the following algorithm, written in pseudocode?
num = 0
Repeat the following steps 10 times
Input var1
If var1 > num
Num = var1
Print num
- To search for a particular number among 10 numbers
- To find the smallest among 10 numbers
- To print out the 10 numbers
- To find the highest among 10 numbers
- Section Ref
- 1.7 Problem Solving: Algorithm Design
- Title
- What is the purpose of this algorithm?
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-77
Consider a situation where you are buying books online. The bookseller charges $19.95 as the price per book and $4.95 as the handling cost for up to three books. For every book purchased in addition to three books, there is a handling charge of $1.50. In addition, there is a 7 percent tax on the cost of the books but not on the handlingCharges
. Assuming that numBooks
represents the number of books you are purchasing, which of the following is the correct algorithm for calculating the total cost of your purchase?
-
Total charge for books = 19.95 * numBooks
Tax on the books = numBooks * .07
if (books < 3) then handlingCharges = 4.95
else handlingCharges = 4.95 + 1.50 * (numBooks – 3)
Total cost of order = total charge for books + tax + handlingCharges
-
Total charge for books = 19.95 * numBooks
Tax on the books = total charge for books * .07
if (books = 3) then handlingCharges = 4.95
else handlingCharges = 1.50 * numBooks
Total cost of order = total charge for books + tax + handlingCharges
-
Total charge for books = 19.95 * numBooks
Tax on the books = total charge for books * .07
if (books <= 3) then handlingCharges = 4.95
else handlingCharges = 4.95 + 1.50 * (numBooks – 3)
Total cost of order = total charge for books + tax + handlingCharges
-
Total charge for books = 19.95 * numBooks
Tax on the books = numBooks * .7
if (books <= 3) then handlingCharges = 4.95
else handlingCharges = 1.50 * numBooks
Total cost of order = total charge for books + tax + handlingCharges
- Section Ref
- 1.7 Problem Solving: Algorithm Design
- Title
- Which is the correct algorithm for calculating total cost with tax/shipping?
- Difficulty
- Hard
- id
- testbank-bjlo-2-ch01-78
Imagine you are planning to buy a new cell phone. You are considering two cell phones. These cell phones have different purchase prices. Each mobile service provider charges a different rate for each minute that the cell phone is used. To determine which cell phone is the better buy, you need to develop an algorithm to calculate the total cost of purchasing and using each cell phone. What are all the inputs needed for this algorithm?
- The cost of each cell phone and the number of minutes provided with each cell phone
- The cost of each cell phone, the rate per minute for each cell phone, and the number of minutes you would use the cell phone
- The cost of each cell phone, the rate per minute for each cell phone, and the number of minutes provided with each cell phone
- The cost of each cell phone and the rate for each minute for each cell phone
- Section Ref
- 1.7 Problem Solving: Algorithm Design
- Title
- Which inputs do you need to calculate cost of purchasing/using cell phone?
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-79
Which one of the following methodologies is a sequence of steps formulated in English for solving a problem?
- Pseudocode
- Terminations
- Flowcharts
- Algorithms
- Section Ref
- 1.7 Problem Solving: Algorithm Design
- Title
- Which methodology is an informal description of steps for solving a problem?
- Difficulty
- Easy
- id
- testbank-bjlo-2-ch01-80
Imagine you are developing an algorithm to calculate the total cost of a purchase order that contains several items. The cost of each item and the tax rate is known. The standard shipping charge for the entire order is $4.95, and the special delivery charge is $19.95. In addition, there is no tax on the shipping cost. Which of the following is the correct pseudocode for the required algorithm?
-
If special delivery
Shipping cost = 4.95
Else
Shipping cost = 19.95
For each item on the purchase order:
Order cost = order cost + item cost
Total purchase order cost = order cost * tax rate + shipping cost
-
If standard shipping
Shipping cost = 4.95
Else
Shipping cost = 19.95
For each item on the purchase order:
Order cost = order cost + item cost + shipping cost
Total purchase order cost = order cost * tax rate
-
For each item on the purchase order:
Order cost = order cost + item cost
If standard shipping
Shipping cost = 4.95
Else
Shipping cost = 19.95
Total purchase order cost = order cost + order cost * tax rate + shipping cost
-
For each item on the purchase order:
Order cost = order cost + item cost
Total purchase order cost = order cost + tax rate + 4.95
- Section Ref
- 1.7 Problem Solving: Algorithm Design
- Title
- Which is the correct pseudocode for algorithm to calculate total cost?
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-81
Evaluate the pseudocode below to calculate the payment (pmt
) with the following test values:
The total number of hours worked (workingHours
) = 50
The rate paid for hourly work (rate
) = 10
Input workingHours
Input rate
pmt = workingHours * rate
If working_hours > 45
extraHours = workingHours – 45
extraPmt = extraHours * rate * 2
pmt = pmt + extraPmt
Output pmt
- 500
- 400
- 600
- 1,000
- Section Ref
- 1.7 Problem Solving: Algorithm Design
- Title
- Evaluate this pseudocode with these test values.
- Difficulty
- Hard
- id
- testbank-bjlo-2-ch01-82
What is the purpose of the following algorithm?
someNum = 0
Repeat the following steps 50 times
Input variable1
if variable1 > someNum
someNum = variable1
Print someNum
- To print out the 50 numbers
- To find the smallest of 50 numbers
- To search for a particular number among 50 numbers
- To find the largest of 50 numbers
- Section Ref
- 1.7 Problem Solving: Algorithm Design
- Title
- What is the purpose of this algorithm?
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-83
Consider a situation where you are buying videos online. The video seller charges $21.50 as the price per video and $6.75 as the handling cost for up to three videos. For every video purchased in addition to three videos, there is a handling charge of $1.50. In addition, there is a 9 percent tax on the cost of the videos but not on the handlingCharges
. Assuming that numVideos
represents the number of videos you are purchasing, which of the following is the correct algorithm for calculating the total cost of your purchase?
-
Total charge for videos = 21.50 * numVideos
Tax on the videos = total charge for videos * .9
if (numVideos = 3) then handlingCharges = 6.75
else handlingCharges = 1.50 * numVideos
Total cost of order = total charge for videos + tax + handlingCharges
-
Total charge for videos = 21.50 * numVideos
Tax on the videos = numVideos * .09
if (numVideos < 3) then handlingCharges = 6.75
else handlingCharges = 6.75 + 1.50 * (numVideos – 3)
Total cost of order = total charge for videos + tax + handlingCharges
-
Total charge for videos = 21.50 * numVideos
Tax on the videos = total charge for videos * .09
if (numVideos <= 3) then handlingCharges = 6.75
else handlingCharges = 6.75 + 1.50 * (numVideos – 3)
Total cost of order = total charge for videos + tax + handlingCharges
-
Total charge for videos = 21.50 * numVideos
Tax on the videos = numVideos * .9
if (numVideos <= 3) then handlingCharges = 6.75
else handlingCharges = 1.50 * numVideos
Total cost of order = total charge for videos + tax + handlingCharges
- Section Ref
- 1.7 Problem Solving: Algorithm Design
- Title
- Which is the correct algorithm for calculating total cost with tax/shipping?
- Difficulty
- Hard
- id
- testbank-bjlo-2-ch01-84
Imagine you are planning to purchase a new cable TV dish. You are considering two cable TV dishes that have different purchase prices. Each channel service provider charges a different rate for each month that the cable TV dish is used. To determine which cable TV dish is the better buy, you need to develop an algorithm to calculate the total cost of purchasing and using each cable TV dish. What are all of the inputs that you need for this algorithm?
- The cost of each cable TV dish and the rate for each month for using each cable TV dish
- The cost of each cable TV dish, the rate per month for using each cable TV dish, and the number of months you would use the cable TV dish
- The cost of each cable TV dish and the number of months you would use the cable TV dish
- The number of months you would use the cable TV dish and the rate per month for using each cable TV dish
- Section Ref
- 1.7 Problem Solving: Algorithm Design
- Title
- Which inputs do you need to calculate cost of purchasing/using cable dish?
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-85
Evaluate the pseudocode below to calculate the payment (pmt
) with the following test values:
The total number of hours worked (workingHours
) = 60
The rate paid for hourly work (rate
) = 15
Input workingHours
Input rate
pmt = workingHours * rate
If workingHours > 40 then
extraHours = workingHours – 40
extraPmt = extraHours * rate * 2
pmt = pmt + extraPmt
Output pmt
- 1,200
- 1,800
- 900
- 1,500
- Section Ref
- 1.7 Problem Solving: Algorithm Design
- Title
- Evaluate this pseudocode with these test values.
- Difficulty
- Hard
- id
- testbank-bjlo-2-ch01-86
Consider the following pseudocode. What does it produce?
Create a list of consecutive integers from two to n: (2, 3, 4, ..., n)
Initially, let p equal 2
Repeat following steps until p is greater than n
Strike from the list all multiples of p less than or equal to n
Find the first number remaining on the list greater than p
Replace p with this number.
- All factorial numbers up to
n
- All Fibonacci numbers up to
n
- All prime numbers up to
n
- All even numbers up to
n
- Section Ref
- 1.7 Problem Solving: Algorithm Design
- Title
- What does the algorithm produce?
- Difficulty
- Hard
- id
- testbank-bjlo-2-ch01-87
Consider the following pseudocode. What does it produce?
Set n to 1
Set p to 1
Repeat until n equals 20
Multiply p by 2 and store result in p
Add 1 to n
Print p
- The product of first 20 numbers
- Two raised to the power 20
- The product of first 20 even numbers
- Factorial of 20
- Section Ref
- 1.7 Problem Solving: Algorithm Design
- Title
- What does the algorithm produce?
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-88
Consider the following pseudocode, what does it produce?
Set n to 1
Set p to 0
Set s to 0
Repeat until n equals 10
Calculate the square of n and store in s
Add s to p
Add 1 to n
Print p
- The product of first 10 numbers
- Two raised to the power 10
- Sum of square of numbers between 1 and 10
- The product of first 10 even numbers
- Section Ref
- 1.7 Problem Solving: Algorithm Design
- Title
- What does the algorithm produce?
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-89
Consider the following pseudocode, what does it produce?
Set n to 0
Set a to 0
Set b to 1
Set p to 1
Print p
Repeat until n equals 10
Set p to a + b
Set a to b
Set b to p
Add 1 to n
Print p
- 1 2 3 4 5 6 7 8 9 10 11
- 1 3 6 9 12 15 18 21 24 27 30
- 1 1 2 3 5 8 13 21 34 55 89
- 1 3 5 7 9 11 13 15 17 19 21
- Section Ref
- 1.7 Problem Solving: Algorithm Design
- Title
- What does the algorithm produce?
- Difficulty
- Hard
- id
- testbank-bjlo-2-ch01-90
Consider the following pseudocode, what does it produce?
Set n to 1
Set p to 1
Repeat until n equals 6
Multiply p by n and store result in p
Add 1 to n
Print p
- 1 1 2 3 5 8
- 1 3 6 9 12 15
- 1 2 6 24 120 720
- 1 2 3 4 5 6
- Section Ref
- 1.7 Problem Solving: Algorithm Design
- Title
- What does the algorithm produce?
- Difficulty
- Medium
- id
- testbank-bjlo-2-ch01-91
Which of these are true about writing algorithms in pseudocode?
I. The exact wording is not important
II. The sequence of steps should be ambiguous
III. The algorithm should terminate
- II and III only
- I and II only
- I and III only
- I, II, and III
- Section Ref
- 1.7 Problem Solving: Algorithm Design
- Title
- What is true when writing pseudocode?
- Difficulty
- easy
- id
- testbank-bjlo-2-ch01-92
A pseudocode step is executable when _____________________________.
- it is precise about where to go next
- it is guaranteed to terminate
- it can be carried out in practice
- it is syntactically correct in a programming language like Java
- Section Ref
- 1.7 Problem Solving: Algorithm Design
- Title
- A pseudocode step is executable when _____?
- Difficulty
- easy
- id
- testbank-bjlo-2-ch01-93
The first step in describing an algorithm in pseudocode is ______________.
- break the algorithm into smaller pieces
- write the steps out in Java code
- test the algorithm by working a problem
- determine the inputs and the outputs
- Section Ref
- 1.7 Problem Solving: Algorithm Design
- Title
- What is the first step in describing an algorithm?
- Difficulty
- easy
- id
- testbank-bjlo-2-ch01-94