AP Comp Sci - Chapter 1

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

What is the parameter in the given method call?

"Welcome"

Parameters to methods are enclosed by these symbols.

( )

What is the file extension of a Java class file?

.class

he Java compiler ignores any text between ____.

/* and */

Text enclosed between this and the end of line is ignored by the compiler.

//

What is the output of the following Java statement? System.out.println(4 + 6);

10

When was Java officially introduced?

1995

Evaluate the given pseudocode to calculate the efficiency of a vehicle's fuel consumption using the following test values: The trip odometer reading (odometer) = 300 The amount to fill the gas tank (amount) = 15 input odometer input amount output odometer/amount What is the final output?

20

Evaluate the given pseudocode to calculate the efficiency of a vehicle's fuel consumption using the following test values: The trip odometer reading (odometer) = 350 The amount to fill the gas tank (amount) = 12 input odometer input amount output odometer/amount

29.2

What is the output of the following Java statement? System.out.println("4 + 6");

46

Evaluate the given pseudocode to calculate the payment (pmt) with the following test values: The total number of hours worked (working_hours) = 50 The rate paid for hourly work (rate) = 10 input working_hours input rate pmt = working_hours * rate if working_hours > 40 then extra_hours = working_hours - 40 extra_pmt = extra_hours * rate pmt = pmt + extra_pmt end of if output pmt What is the final output?

600

Evaluate the given pseudocode to calculate the weighted score for a student: The average program score (program) = 92 The weight of programs (pgmWeight) = 40% The average exam score (exams) = 85 The weight of exams(exWeight) = 60% input program input pgmWeight input exams input exWeight output program*pgmWeight + exams*exWeight

87.80

Evaluate the given pseudocode to calculate the weighted score for a student: The average homework score (homework) = 95 The weight of homework (hwWeight) = 35% The average exam score (exams) = 87 The weight of exams(exWeight) = 65% input homework input hwWeight input exams input exWeight output homework*hwWeight + exams*exWeight What is the final output?

89.80

Evaluate the given pseudocode to calculate the payment (pmt) with the following test values: The total number of hours worked (working_hours) = 60 The rate paid for hourly work (rate) = 12 input working_hours input rate pmt = working_hours * rate if working_hours > 40 then extra_hours = working_hours - 40 extra_pmt = extra_hours * rate pmt = pmt + extra_pmt output pmt What is the final output?

960

In Java, every statement must end with this symbol.

;

What is a Java library?

A collection of code that has been programmed and translated by someone else, ready for you to use in your program.

Which statement best describes a computer program?

A program is a sequence of instructions and decisions that the computer carries out.

What is the JVM?

A virtual machine that runs compiled Java code on any CPU.

What is the name of the file that contains the Java source code for the class BankAccount?

BankAccount.java

What does CPU stand for?

Central Processing Unit

Which statement regarding computer programs is correct?

Computer programs are composed of extremely primitive operations.

What does a class file contain?

Instructions for the Java Virtual Machine.

Which statement is true about a Java program?

Java is case sensitive.

Suppose that a computer virus infects your computer and corrupts the files you were going to submit for your current homework assignment. What precaution could have saved you from a disastrously bad grade for this assignment?

Make regular backups of all your important files.

What is the name of the class declared in the file MyClass.java?

MyClass

What is the name of the file created after a successful compilation of MyClass.java?

MyClass.class

What is the name of the file declaring the class named MyClass?

MyClass.java

Assume that the following Java statement is contained in the main method of the class named Hello: System.out.printLine("Hello!"); What is the name of the file generated by the Java compiler?

No file is generated due to an error.

Assume that the following Java statement is contained in the main method of the class named Welcome: System.out.printLine("Welcome!"); What is the name of the file generated by the Java compiler?

No file is generated due to an error.

Which one of the following is NOT a function of a CPU?

Querying a database

Which one of the following memory types provides storage that persists without electricity?

Secondary storage

What is defensive programming?

Structuring programs and development processes in such a way that an error in one part of the program does not trigger a disastrous response.

What is the object in the given method call?

System.out

What is the syntax for calling the println method on the object System.out?

System.out.println("Any message");

Which of the following statements is true about running a Java program?

The Java virtual machine loads the instructions for the program that you wrote, starts your program, and loads the necessary library files as they are required.

Which statement is true about the compilation process?

The compiler will continue compiling after it finds an error.

Which statement best describes the portability characteristic of Java?

The same Java class files will run on different operating systems without change.

Assuming the programmer wishes to display "Hello!" on the screen, which statement is true about the following Java statement: System.out.printn("Helo!");

There are multiple errors.

Assuming the programmer wishes to output the phrase "Welcome!", which of the following is true about the following Java statement. System.out.Println("Wlcome!");

There are multiple errors.

Assuming the programmer wishes to display "Hello!" on the screen, which statement is true about the following Java statement: System.out.println("Hello!");

There are no errors.

Which statement is true about the following Java statement: System.out.println("Welcome!");

There are no errors.

Which statement is true about the following Java statement: System.out.Println("Welcome!");

There is a compile-time error.

Which statement is true about the following Java statement: System.out.println("Hello!);

There is a compile-time error.

Assuming the programmer wishes to display "Hello!" on the screen, which statement is true about the following Java statement: System.out.println("Helo!");

There is a run-time error.

Assuming the programmer wishes to output the phrase "Hello!", which of the following is true about the following Java statement. System.out.println("Welcme!");

There is a run-time error.

What is the purpose of the following algorithm? num = 0 Repeat the following steps for 10 times input var1 if var1 > num then num = var1 print num

To find the largest among 10 numbers

What is the purpose of the following algorithm? somenum = 0 Repeat the following steps for 15 times input variable1 if variable1 < somenum then somenum = variable1 print somenum

To find the smallest among 15 numbers.

Which statement is true about running a Java program on a different CPU?

You can take code that has been generated by the Java compiler and run it on different CPUs.

Which of the following options is true about algorithms?

You must create an algorithm for a problem before you can create a program to solve the problem.

Which one of the following statements regarding backup strategies for Java files is correct?

You should have multiple copies of your source files in different locations.

What term is used to refer to a sequence of steps for solving a problem that is unambiguous, executable, and terminating?

algorithm

What is the term used to refer to Java code that runs in a browser?

applet

What are the electrical lines called that interconnect the CPU, RAM, and the electronics controlling the hard disk and other devices?

bus

Every Java program consists of one or more of these fundamental building blocks.

class

The Java compiler translates source code into what type of file?

class

What term is used to refer to text in a program that helps human readers understand the program?

comments

What is the term used to describe an error detected by the compiler that is a violation of the programming language rules?

compile-time error

What translates Java source code files into files that contain instructions for the JVM?

compiler

What translates high level descriptions into machine code?

compiler

What are special software tools called that let you trace through a program to find run-time errors?

debugger

Structuring programs and development processes in such a way that an error in one part of the program does not trigger a disastrous response is referred to as ____.

defensive programming

What type of program can you use to enter your Java program?

editor

A step sequence that can be carried out in practice is ______________.

executable

Which of the following is not contained on the motherboard of a computer?

hard disk

Which type of secondary storage consists of rotating platters, which are coated with a magnetic material, and read/write heads, which can detect and change the patterns of varying magnetic flux on the platters?

hard disk

What term is used to refer to languages that allow programmers to describe tasks at a higher conceptual level than machine code?

high-level

What is the correct order of the steps in the program development process: i. Develop and describe the algorithm. ii. Translate the algorithm into Java. iii. Understand the problem. iv. Compile and test the program. v. Test the algorithm with different inputs.

iii, i, v, ii, iv

A step sequence is executable when ___________________________

it can be carried out in practice.

A step sequence is terminating when ___________________________

it will eventually come to an end.

In a console window, what is the name of the command used to run a Java program?

java

In a console window, assuming that BankAccountTester includes the main method, how do you run the program?

java BankAccountTester

In a console window, assuming that MyClass includes the main method, how do you run the program?

java MyClass

In a console window, what is the name of the command used to compile Java source code?

javac

In a console window, how do you compile the declaration of the class BankAccount?

javac BankAccount.java

In a console window, how do you compile the declaration of the class MyClass?

javac MyClass.java

A(n) ____ is a collection of code that has been programmed and translated by someone else, ready for use in your program.

library

What is another term used to describe an error causing a program to take an action that the programmer did not intend?

logic error

What term is used to refer to the computer instructions that are executed by a CPU, which are specific to each CPU?

machine code

When a Java application starts, what is the name of the method that is executed?

main

A __________ contains sequences of instructions to perform a particular task.

method

Which part of a computer contains the CPU, the RAM, and connectors to peripheral devices?

motherboard

A method is called on what entity in the program?

object

What entity belongs to a class and is manipulated in a program?

object

A method may be called by specifying which 3 items in the specified order?

object, method name, parameters

What term is used to refer to information passed in to a method on a call?

parameter

For a program to be executed, where must it reside so that the CPU can read its instructions?

primary memory

Which memory type does not provide persistent storage?

primary storage

Which type of storage is made from memory chips?

primary storage

What is the name of the method in the given method call?

println

Who or what is responsible for inspecting and testing the program to guard against logic errors?

programmer

What term is used to refer to an informal description of a sequence of steps for solving a problem?

pseudocode

What is the term used to describe an error causing a program to take an action that the programmer did not intend?

run-time error

What is another term used to describe an error detected by the compiler that is a violation of the programming language rules?

semantic error

What term is used to refer to an instruction in a method?

statement

What term is used to refer to a sequence of characters enclosed in quotation marks?

string

A step sequence that eventually comes to an end is ______________.

terminating

A step sequence is unambiguous when ___________________________

there are precise instructions for what to do at each step and where to go next.

A step sequence that contains precise instructions for what to do at each step and where to go next is ______________.

unambiguous


Conjuntos de estudio relacionados

Business Intelligence Mid-Term E

View Set

Ch. 4 "The Carbohydrates: Sugars, Starches, & Fiber" - 4.3 "Glucose in the Body"

View Set

Chapter 14 Managing Engagement and Turnover

View Set

Matter and Periodic Table Review

View Set

Unified Science Chapter 13 (Stars and Galaxies), Section 4: Galaxies and the Universe, pp. 386-391.

View Set

Muscle Origin, Insertion, and Action

View Set