The rules that govern the correct order and usage of the elements of a language are called the______ of the language
Front
Syntax
Back
To run a Java program from a command line, we use the ________ command.
Front
Java
Back
Declare a variable x , suitable for storing values like 3.14159 and 6.02E23.
Front
double x;
Back
Write a complete main method that prints Hello, world to the screen.
Front
public static void main( String[] helloWorld )
{
System.out.println("Hello, world");
}
2) Print out a name:
{
System.out.println("Turing, Alan");
}
Back
Which of the following IS a legal identifier?
A) 5_And_10
B) Five_&_Ten
C) ___________
E) LovePotion#9
F) "Hello World"
Front
C) ___________
Back
Which statement is NOT true:
A) Machine languages can be used to express algorithms.
B) Machine languages can be used to write programs that can run on any machine.
C) Machine language consists of zeros and ones.
D) Machine language is produced by compilers.
Front
B: Machine languages can be used to write programs that can run on any machine.
Back
The purpose of testing a program with different combinations of data is to expose run-time and _________ errors.
Front
Logic.
Back
Which of the following is NOT a legal identifier?
A) outrageouslyAndShockinglyLongRunon
B) _42
C) _
D) lovePotionNumber9
E) 7thheaven
Front
E) 7thheaven
Back
Changing the flow of control in a program to jump to some pre-written code is known as ___________ a method.
Front
Calling.
Back
Choose: An operating system
a. is the chief hardware unit of a computer
b. is loaded into the computer each time it needs to carry out an operation
c. ensures that programs will not run on the computer at the same time
d. allocates resources like memory to programs that are running
Front
D. Allocates resources like memory to programs that are running.
Back
Before a variable is used it must be
A) defined
B) declared
C) imported
D) evaluated
E) assigned
Front
B) declared
Back
An identifier that cannot be used as a variable name is a ___________ word.
Front
Reserved; (Reserved words are words, such as null, true, false.)
Back
A location in memory used for storing data and given a name in a computer program is called a _________ because the data in the location can be changed.
Front
variable
Back
When a program is not running, it is stored on_________.
Front
A disk.
Back
Write a single statement that will print the message "first is " followed by the value of first, and then a space, followed by "second = ", followed by the value of second. Print everything on one line and go to a new line after printing. Assume that first has already been declared as a double and that second has been declared as an int . Assume also that the variables have already been given values .
Front
System.out.println("first is " + first + " second = " + second + " ");
Back
Which of the following is not true?
A) An algorithm allows ambiguity.
B) An algorithm, when carried out, must eventually stop.
C) An algorithm, can be carried out by a human being.
Front
A) An algorithm allows ambiguity.
Back
Carrying out the steps of a program, starting with the first, then the second and proceeding to the last is known as _______ processing.
Front
sequential.
Back
Declare a float variable named price .
Front
float price;
Back
Define Method.
Front
A method is a set of code which is referred to by name and can be called (Envoked).
Back
In a network, a computer that performs specific services for other computers on the network is called a _____.
Front
Server.
Back
Write a complete program whose class name is Hello and that displays Hello, world on the screen.
Front
//Smith, Trevor//
//Hello//
public class Hello
{public static void main( String[] HEllo)
{ System.out.println( "Hello, world");
}
}
Back
In Java, an argument is
A) a logical sequence of statements proving the correctness of a program.
B) information that a method returns to its caller.
C) information provided to a method.
D) a verbal dispute.
Front
C) information provided to a method.
Back
Suppose your name was George Gershwin. Write a complete main method that would print your last name , followed by a comma, followed by aspace and your first name .
Front
public static void main( String[] nameGame)
{
System.out.println("Gershwin, George");
}
Back
Assume that message is a String variable . Write a statement to display its value on standard output .
Front
System.out.println(message);
Back
Of the following variable names, which is the best one for keeping track of whether a patient has a fever or not?
A) temperature
B) feverTest
C) hasFever
D) fever
Front
C) hasFever
Back
Mice, trackpads, keyboards, scanners, joysticks are all examples of________.
Front
input devices.
Back
In object-oriented programming a class is
A) a group of people sharing the same relationship to the means of production.
B) the term used for program.
C) a model or template from which objects are created.
D) a grouping of users sharing common objectives.
E) a procedure for a calculation inside a program.
Front
C) a model or template from which objects are created.
Back
Mice, trackpads, keyboards, scanners, joysticks are all examples of________.
Front
Output devises.
Back
Which of the following is NOT a Java reserved word?
A) public
B) int
C) main
D) static
E) void
Front
A) public
Back
Declare a double variable named netWeight .
Front
double netWeight;
Back
Declare two integer variables named profitStartOfQuarter and cashFlowEndOfYear .
Front
int profitStartOfQuarter, cashFlowEndOfYear;
Back
How do you print "Programming is not a spectator sport!"?
Front
System.out.println( "Programming is not a spectator sport!" );
Back
An error in a program that involves a violation of language rules will be detected at ____________ time.
Front
compile.
Back
When a program runs on a computer, it is stored in_______.
Front
Random Access Memory(RAM)
Back
When a program runs on a computer, the part of the computer that carries out the instructions is called the_____
Front
Central Processing Unit(CPU)
Back
Which of the following names in a program is equivalent to the name int?
A ) Int
B) INT
C) All of the above
D) None of the above
Front
D) None of the above
Back
The standard name of the Java compiler is _______?
Front
Jvac
Back
In a network, a computer that requests specific services for other computers on the network is called a ________.
Front
Client.
Back
Assume that word is a String variable . Write a statement to display the message "Today's Word-Of-The-Day is: " followed by the value of word on a line by itself on standard output .
Front
System.out.println ("Today's Word-Of-The-Day is: "+ word);
Back
Of the following variable names, which is the best one for keeping track of whether an integer might be prime or not?
A) divisible
B) isPrime
C) mightBePrime
D) number
Front
C) mightBePrime
Back
Words that have a special meaning in a programming language are called _________ .
Front
Key words
Back
Division by zero when the program is executing is an example of a ______________ error.
Front
run-time.
Back
A compiler
A) maintains a collection of programs
B) tests a program's logic
C) translates source code into executable code
D) translates executable code to machine code
Front
C) Translates source code into executable code.
Back
Files containing Java code must end with what "extension"? .
Front
Java
Back
Declare an integer variable named degreesCelsius .
Front
int degreesCelsius;
Back
Define Indentifieres:
Front
Indentifirs are symbolic names you give to your class, metod, or and data. Indintifiers must start with a Java letter and may contain any combinatuin of letters, but no spaces.
Back
In object-oriented programming a method is
A) A design technique for creating classes.
B) A disciplined way of writing programs.
C) An approach developed by the great Stanislawski.
a process for instantiating an object.
D) Code that allows access to an object's attributes or that carries out some other action for the object.
Front
D) Code that allows access to an object's attributes or that carries out some other action for the object.
Back
Declare a long integer variable named grossNationalProduct .
Front
long grossNationalPark;
Back
Print statement to say "hello world"
Front
System.out.println("Hello, world");
Back
A comment starts with what characters?
Front
//
Back
Section 2
(50 cards)
Declare a variable isACustomer suitable for representing a true or false value .
Front
boolean isACustomer;
Back
The character escape sequence to represent a single quote is: _________
Front
\'
Back
Declare and initialize the following variables :
• monthOfYear , initialized to the value 11
• companyRevenue , initialized to the value 5666777
• firstClassTicketPrice , initialized to the value 6000
• totalPopulation , initialized to the value 1222333
Front
int monthOfYear = 11;
long companyRevenue = 5666777;
long firstClassTicketPrice = 6000;
long totalPopulation = 1222333;
Back
Write a literal corresponding to the floating point value one-and-a-half.
Front
1.5f
Back
The character escape sequence to force the cursor to advance forward to the next tab setting is: ____________
Front
\t
Back
Assume that children is an integer variable containing the number of children in a community and that families is an integer variable containing the number of families in the same community. Write an expression whose value is the average number of children per family.
Front
(double) children/families
Back
Declare an integer constant , MONTHS_IN_YEAR , whose value is 12 .
Front
Final int MONTH_IN_YEAR = 12;
Back
The character escape sequence to force the cursor to go to the next line is: _______________
Front
Back
Declare a constant MONTHS_IN_DECADE , whose value is the value of the constant MONTHS_IN_YEAR (already declared ) multiplied by 10 .
Front
final int MONTHS_IN_DECADE = MONTHS_IN_YEAR * 10;
Back
The dimensions (width and length) of room1 have been read into two variables : width1 and length1 . The dimensions of room2 have been read into two other variables : width2 and length2 . Write a single expression whose value is the total area of the two rooms.
Front
(width1length1)+(width2length2)
Back
Write an expression that computes the average of the values 12 and 40 .
Front
(12+40) / 2
Back
Write a literal representing the long integer value twelve billion.
Front
12000000000L
Back
You are given two double variables , already declared and assigned values , named totalWeight , containing the weight of a shipment, and weightOfBox , containing the weight of the box in which a product is shipped. Write an expression that calculates the net weight of the product .
Front
totalWeight - weightOfBox
Back
Assume that price is an integer variable whose value is the price (in US currency) in cents of an item. Assuming the item is paid for with a minimum amount of change and just single dollars, write an expression for the number of single dollars that would have to be paid.
Front
price/100
Back
The value of the expression 12%0 is
A) 0
B) 12
C) undefined
Front
C) undefined
Back
Assume that price is an integer variable whose value is the price (in US currency) in cents of an item. Assuming the item is paid for with a minimum amount of change and just single dollars, write an expression for the amount of change (in cents) that would have to be paid.
Front
price%100
Back
Which token is a literal?
A) 77
B) main
C) int
D) +
E) salary
Front
A) 77
Back
Write a String constant that is the empty string .
Front
""
Back
Write a literal representing the integer value zero.
Front
0
Back
In mathematics, the Nth harmonic number is defined to be 1 + 1/2 + 1/3 + 1/4 + ... + 1/N. So, the first harmonic number is 1, the second is 1.5, the third is 1.83333... and so on. Assume that n is an integer variable whose value is some integer N greater than 1. Assume also that hn is adouble variable whose value is the Nth harmonic number. Write an expression whose value is the (N-1)th harmonic number.
Front
hn - 1.0/(n*1)
Back
Calculate the average (as a double ) of the values contained the integer variables num1, num2, num3 and assign that average to the double variable avg.
Assume the variables num1, num2, and num3 have been declared and assigned values , and the variable avg declared .
Front
avg = (double) (num1+num2+num3) / 3;
Back
The quotient that results from dividing 23 by 5 is
A) 4.6
B) 3
C) 4
Front
C) 4
Back
Declare a variable temperature and initialize it to 98.6 .
Front
double temperature = 98.6;
Back
Write a character literal representing a comma.
Front
","
Back
The remainder that results from dividing 30 by 10 is
A) 0
B) 3
C) 300
D) 30
Front
A) 0
Back
Each of the walls of a room with square dimensions has been built with two pieces of sheetrock, a smaller one and a larger one. The length of all the smaller ones is the same and is stored in the variable small . Similarly, the length of all the larger ones is the same and is stored in thevariable large . Write a single expression whose value is the total area of this room. DO NOT any method invocations.
Front
(small + large) * (small + large)
Back
Write a hexadecimal integer literal representing the value fifteen.
Front
0xF
Back
The character escape sequence to represent a backslash is:
Front
\\
Back
The value of the expression 23%5 is
A) 4
B) 3
C) 23
D) 1
Front
B) 3
Back
Declare two double variables , one named length with a value of 3.5 and the other named width with a value of 1.55 .
Front
double length = 3.5, width = 1.55;
Back
Given an integer variable drivingAge that has already been declared , write a statement that assigns the value 17 todrivingAge .
Front
drivingAge = 17;
Back
Given two integer variables distance and speed , write an expression that divides distance by speed using floating point arithmetic, i.e. afractional result should be produced.
Front
(double) distance / speed
Back
The character escape sequence to represent a double quote is:
Front
\"
Back
Write an expression that computes the sum of two variables verbalScore and mathScore (already declared and assigned values ).
Front
verbalScore + mathScore
Back
Write a long integer literal that has the value thirty-seven _______ .
Front
37L
Back
In mathematics, the Nth harmonic number is defined to be 1 + 1/2 + 1/3 + 1/4 + ... + 1/N. So, the first harmonic number is 1, the second is 1.5, the third is 1.83333... and so on. Assume that n is an integer variable whose value is some positive integer N. Assume also that hn is a variable whose value is the Nth harmonic number. Write an expression whose value is the (N+1)th harmonic number.
Front
hn + 1.0/(n+1)
Back
In mathematics, the Nth harmonic number is defined to be 1 + 1/2 + 1/3 + 1/4 + ... + 1/N. So, the first harmonic number is 1, the second is 1.5, the third is 1.83333... and so on. Write an expression whose value is the 8th harmonic number.
Write an expression that computes the difference of the variables endingTime and startingTime .
Front
endingTime - startingTime
Back
Assume that price is an integer variable whose value is the price (in US currency) in cents of an item. Write a statement that prints the value of price in the form "X dollars and Y cents" on a line by itself. So, if the value of price was 4321, your code would print "43 dollars and 21 cents". If the value was 501 it would print "5 dollars and 1 cents". If the value was 99 your code would print "0 dollars and 99 cents".
Write a literal corresponding to the value of the first 6 digits of PI ("three point one four one five nine").
Front
3.14159
Back
Declare a variable hasPassedTest , and initialize it to true .
Front
A) boolean hasPassedTest = true;
Back
Write an expression that computes the remainder of the variable principal when divided by the variable divisor . (Assume both are type int .)
Front
principal % divisor
Back
The % operator calculates
A) a percentage
B) a ratio
C) the remainder
D) the quotient
Front
C) the remainder
Back
Assume that an int variable x that has already been declared ,. Write an expression whose value is the last (rightmost) digit of x .
Front
x%10
Back
The value of the expression 35%7 is
A) 0
B) 3
C) 5
D) 1
Front
A) 0
Back
Which token is NOT a keyword (language-determined identifier)?
A) int
B) sum
C) double
D) return
E) char
Front
B) sum
Back
Declare an integer variable cardsInHand and initialize it to 13 .
Front
Short cardsInHand = 13;
Back
The remainder that results from dividing 23 by 5 is
A) 4
B) 3
C) 23
D) 1
Front
B) 3
Back
Write a literal representing the largest character value
Front
65525
Back
Write a character literal representing the (upper case) letter A.
Front
"A"
Back
Section 3
(9 cards)
Given an integer variable strawsOnCamel , write a statement that uses the auto-increment operator to increase the value of that variable by 1 .
Front
strawsOnCamel ++;
Back
Consider this code: "int v = 20; --v; System.out.println(v++);". What value is printed, what value is v left with?
A) 20 is printed, v ends up with 19
B) 19 is printed, v ends up with 20
C) 20 is printed, v ends up with 20
D) 19 is printed, v ends up with 19
E) cannot determine what is printed, v ends up with 20
Front
B) 19 is printed, v ends up with 20
Back
Given an integer variable profits , write a statement that increases the value of that variable by a factor of 10 .
Front
profits = profits * 10;
Back
Consider this code: "int s = 20; int t = s++ + --s;". What are the values of s and t?
A) s is 19 and t is 38
B) s is 20 and t is 39
C) s is 19 and t is 39
D) s is 20 and t is 40
E) s is 20 and t cannot be determined
Front
D) s is 20 and t is 40
Back
Three classes of school children are selling tickets to the school play. The number of tickets sold by these classes, and the number of children in each of the classes have been read into these variables : tickets1 , tickets2 , tickets3 and class1 , class2 , class3 . Write an expression for the average number of tickets sold per school child.