Quiz 1

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

contains instructions for the Java virtual machine

A Java "class" file _______________________. contains Java source code is an internal file created by the Integrated Development Environment (IDE) contains instructions for the Java virtual machine is the translation of the Java source code into C++

software

A Java virtual machine is ____________. hardware firmware applet software

a Central Processing Unit (CPU)

A single silicon chip made from potentially millions of transistors is called ______________. secondary Storage a Central Processing Unit (CPU) an Optical Disk (such as a DVD) a Hard Disk

a microphone

An example of an input device that interfaces between computers and humans is ____________. a printer a monitor a microphone a speaker

execute programs

Computers are machines that __________________. execute programs are imprecise and slow design computer programs carry out a very narrow range of tasks

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

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 * .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

1,500

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,800 1,200 900 1,500

classes

Every Java program consists of one or more ___________. values (arguments) strings classes System.out.println statements

the semi-colon character ;

Every statement in Java must be terminated with ____________. the semi-colon character ; a carriage return System.out.println() an escape sequence

Java programs are compiled to instructions for a virtual machine.

How does Java achieve portability? Java programs are compiled to instructions in the C++ programming language. Java programs are interpreted. Java programs are compiled to instructions for a virtual machine. Java programs must be re-compiled on each platform where they are to run.

is a legal statement

In Java, the following statement ____________________. System.out.print("hello");;; seems like it should print out "hello" but doesn't is a syntax error is a legal statement asks the user to enter a value and stores it in the variable "hello"

virtual machine

In order to run Java programs on a computer, the computer needs to have software called a(n) __________. virtual machine assembler debugger windows

No, because Java is case-sensitive, these are considered to be completely distinct.

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 Java is case-sensitive, these are considered to be completely distinct. Yes, because these Java symbols both have the same letters, they are considered to be the same No, because helloprinter is misspelled, the Java compiler will reject it. Yes, because all Java symbols must have exactly twelve characters.

library packages

The Java programming language is itself relatively simple, but also contains a vast set of _______________. program templates syntactical variations library packages cross-platform scripting languages

run-time errors

The programmer, not the compiler, is responsible for testing a program to identify _________________. undefined symbols compile-time errors run-time errors syntax errors

that ends with a .java suffix

The source code for a Java program is stored in a file ________________. that ends with a .java suffix that can have any valid file name that ends with a .class suffix that has no suffix

Problems solved in a high-level language are independent of the underlying computer hardware.

What is one of the benefits of using a high-level programming language like Java? No tools other than a text editor are required for programming. 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.

HelloGood Day!

What is the output of the following code snippet? System.out.print("Hello"); System.out.println("Good Day!"); HelloGood Day! HelloGoodDay! Hello Good Day! Hello Good Day!

812

What is the output of the following code snippet? System.out.print(4 + 4); System.out.print(12); 812 4 + 412 20 4412

4 * 412

What is the output of the following code snippet? public class PrintIt { public static void main(String[] args) { System.out.println("4 * 4" + 12); } } 1612 28 4412 4 * 412

To find the highest among 10 numbers

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 highest among 10 numbers To find the smallest among 10 numbers To print out the 10 numbers

System.out.println();

Which Java statement does not contain an error? System.out.printl(); System.out.print() System.out.print(; System.out.println();

software

Which of the following refers to a collection of programs that a computer executes? software instructions assembler source code

System.out.print("Hello "); System.out.println("Good Day!");

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!");

compiler

Which one of the following translates high-level descriptions into machine code? compiler editor assembler linker

I, II, and III

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 II and III only I and II only I and III only

logic error

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? logic error hardware error syntax error compile-time error


Ensembles d'études connexes

Risk/Insurance Exam 3 Irrevocable Life Insurance Trust (ILIT)

View Set

Unit 2: Biological Bases of Behavior

View Set

EXSC 351- Acquisition of Motor Skills Quizes

View Set

Chapter 10, Psychology of adjustment

View Set

Alla viktiga frågor från duggor

View Set

Chapter 68: Childhood Immunization

View Set

Costs of Goods Sold Assignment and Quiz 100%

View Set

STC Series 7 Chapter 9, 10, and 11: Investment Companies, Variable Products, and Alternative Products

View Set