Shared Flashcard Set

Details

Computer Science Midterm
Computer Science
40
Computer Science
Undergraduate 2
10/08/2015

Additional Computer Science Flashcards

 


 

Cards

Term
Applet
Definition
A type of program which is designed to be transmitted over the Internet and run in a Web browser.
Term
String
Definition
The following snippet of code appears in a Java program. It can be most appropriately described as a_____________________

"Hello World"
Term
Exception
Definition
A class that signals a condition that prevents a program from continuing, and subsequently generates an error message from the Java Virtual Machine is called a(n)__________________.
Term
Algorithm
Definition
An unambiguous, executable, and terminating specification of a way to solve a problem is called a(n) _____________________.
Term
Source code
Definition
Instructions in a Programming Language that need to be translated before execution on a computer.
Term
28
Definition
Trace the following algorithm. What would it output (display)?

Set a to 10
Set b to 2
Set c to 4
Set a to (a x b)
Set c to (b x c)
Set b to (a + c)
Print b
Term
RAM (primary storage)
Definition
What type of memory is usually volatile (ie. is erased when electrical power is turned off)?
Term
when the program is running
Definition
A syntax error is usually detected during:
Term
compile-time error
Definition
A program logic error that occurs after a program has successfully compiled and is subsequently run is referred to as a:
Term
It is ambiguous
Definition
The following algorithmic psuedocode calculates the area of a triangle. What is the problem with this code?

Area = 1/2 x base x height
Get base
Get height
Print Area
Term
3.14 = PI;
Definition
Which of the following is not an example of a valid assignment statement (Assume all variables have been properly declared, and if needed also initialized):
Term
/*
Definition
These characters mark the beginning of multi-line comments:
Term
nextInt
Definition
Which Scanner Class method would you use to read an integer as input?
Term
next
Definition
Which Scanner class method would be most approriate to read textual(string) input into a program?
Term
Cast
Definition
Which type of operator allows you to manually convert a value to a value of a different data type.
Term
Double
Definition
The following is a primitive data type:
Term
H!
Definition
What does the following Java code sequence print?


String str = "Hello World!";
int n = str.length();
String shortString = str.substring(0,1) + str.substring(n-1, n);
System.out.println(shortString);
Term
age = Integer.parseInt(str);
Definition
Given the Java code:

int age;
String str;
str = JOptionPane.showInputDialog("Enter your age: ");
Term
6
Definition
What does the following Java code sequence print?

int m = 18;
int n = 4;
System.out.println(m/n + m%n);
Term
False
Definition
True or False: When you are accumulating a sum of numbers, it is not necessary to initialize the variable to hold the sum.
Term
True
Definition
True or False: A variable may be declared in the initialization expression of the for loop.
Term
The loop will iterate infinitely.
Definition
What happens when you place a semicolon immediately after the condition in the while loop below?


int i = 0;

while (i < 10);

{

System.out.println(i + " ");

i++;

}
Term
3 5 7 9 11
Definition
What will the following code print out ?

int count = 1;
while (count <= 10)
{
count = count + 2;
System.out.print(count + " ");
}
Term
do-while
Definition
This type of loop always executes at least once and is classified as a post-test loop.
Term
x
Definition
In the following code segment, which variable is the loop control variable?

int a, x = 1, y = 5;
while (x < 100)
{
a = x*x;
y*= x;
x++;
}
Term
3, 4, 1 , 2
Definition
In what numerical order do the following things happen in a for loop that uses a loop control variable ?

1. The loop body is executed.

2. The loop control variable is updated.

3. The loop control variable is initialized.

4. The loop control variable is tested, and if true...
Term
9
Definition
How many iterations would the following loop carry out?

(Assume that i is not changed in the loop body).

for (int i = 1; i < 10; i++)
{
// do something useful ...
}
Term
12
Definition
In the following loop, how many times will "Java is great!!!" be printed?

for (int count = 10; count <= 21; count++)
{
System.out.println("Java is great!!!"+ count);
}
Term
Validating input
Definition
According to the author of your text, do Loops are commonly used when _________________.
Term
Control is returned to method C
Definition
If method A calls Method B, and method B calls method C, and method C calls method D, when method D finishes, what happens?
Term
Its value is copied into the method's parameter variable
Definition
When an argument is passed to a method,
Term
Do not include the data type in the method call
Definition
What is wrong with the following method call?

displayValue (double x);
Term
displayValue(a,b); where a is an integer and b is an integer
Definition
Given the following method header, which of the method calls would NOT be an error?

public void displayValue(int x, int y)
Term
Are lost between calls to the method in which they are declared
Definition
Values stored in local variables
Term
Stepwise Refinement
Definition
The process of breaking a problem down into smaller pieces is called
Term
True
Definition
True or False. When a method is called, the value passed to a formal parameter within the method heading is referred to as an argument (or actual parameter).
Term
showProduct(3.3, 55);
Definition
Which of the following would be a valid method call for the following method?

public static void showProduct(double num1, int num2)
{
double product;
product = num1 * num2;
System.out.println("The product is " + product);
Term
True
Definition
True or False. The scope of a variable is the part of the program in which it is accessible.
Term
True
Definition
True or False. Two local or parameter variables can have the same name, provided that their scopes do not overlap.
Term
True
Definition
True or False. The scope of a local variable declared in a program block (or method) begins when it is declared and ends when the program block (or method) terminates.
Supporting users have an ad free experience!