Shared Flashcard Set

Details

Exam 1 Questions
N/A
74
Computer Science
Undergraduate 2
04/27/2013

Additional Computer Science Flashcards

 


 

Cards

Term
An ______ is a finite sequence of steps that solves some well-defined problem
Definition
Algorithm
Term
_____ is a set of natural language-like statements that describe, at various levels of detail, the steps an algorithm must take to solve a problem and the order in which those steps should be taken.
Definition
Pseudocode
Term
Another term for ______ is information hiding
Definition
Encapsulation
Term
True/False: Polymorphism is a classification system for organizing classes in Java.
Definition
False
Term
True/False: In Java, the double equal sign means "make equal to".
Definition
False
Term
The term ______ refers to a way of organizing classes that share properties
Definition
Inheritance
Term
______ means that two or more methods can have different names in the same way that an English word can have two or more meanings.
Definition
Polymorphism
Term
A ______ occurs when a program has a grammatical mistake like missing punctuation.
Definition
Syntax error
Term
If the computer displays an error message while executing your program, the program contains a(n) __________.
Definition
run-time error
Term
In Java, a library of classes is called
Definition
a package
Term
Single quotes are used with constants of the ____ type.
Definition
char
Term
True/False: Use of a type cast from double to int sometimes causes values to be rounded.
Definition
False
Term
True/False: ice-cream is an illegal identifier in Java.
Definition
True
Term
True/False: A common practice that is used in the textbook is to start the names of variables with a capital letter.
Definition
False
Term
Which of the following is a class type? (Int, double, char, string)
Definition
String
Term
Which of the following is not an integer type? (double, short, byte, int)
Definition
double
Term
Which of the following is a correct statement in Java? (apes = monkeys + gorillas, tigers = 3, lions + tigers = cats;, zebras += 5;)
Definition
zebras += 5;
Term
println is a method used with __________
Definition
the System.out object
Term
Which of the following assignments would not be allowed without a typecast? (assigning a short value to a long variable, assigning a byte value to a double variable, assigning an int value to a float variable, assigning a double value to a long variable)
Definition
assigning a double value to a long variable
Term
Which of the following operators has the highest precedence? (unary +, binary +, %, *)
Definition
unary +
Term
A number like 60 in a program should (be replaced with a variable that has the same value, be replaced with a named constant, be explained by a comment, be written as '60' if used as an integer)
Definition
be replaced with a named constant
Term
Words that have predefined meanings in Java and cannot be used as variable names are called
Definition
key words
Term
A case label is used with a(n)____ statement
Definition
switch
Term
True/False: A multibranch if-else statement is one kind of nested if-else statement.
Definition
True
Term
True/False: The body of any while loop will be executed at least once.
Definition
False
Term
True/False: for loops and while loops use the same stopping mechanism.
Definition
False
Term
True/False: In ASCII, a capital 'Z' comes before a small 'a'.
Definition
True
Term
A(n) __________ goes in the parentheses following the word if in an if-else statement.
Definition
boolean expression
Term
What is the correct way to end a program’s execution normally?
Definition
System.exit(0);
Term
A(n) _____ is an action that an object can take and is specified in the class definition.
Definition
method
Term
Compiling a file called Game.java will produce a file called ____
Definition
Game.class
Term
____ is the word used to say that there are no restrictions on the use of a method or data item.
Definition
public
Term
The reserved word ____ can be used as a name for the calling object.
Definition
this
Term
Names of mutator methods usually begin with ____
Definition
set
Term
To create an object of a class type, the key word ____ is used
Definition
new
Term
One kind of method returns a value. The other kind of method is called a(n) _____
Definition
void method
Term
A ____ is the definition(or blueprint) of a kind of object.
Definition
class
Term
A variable declared inside a method is called a ______ variable
Definition
local
Term
True/False: All objects of the same class have the same data values.
Definition
False
Term
True/False: When a method call is executed, values from the method definition are substituted for the arguments in the method call.
Definition
False
Term
True/False: Parameters of a primitive type are passed to methods using the call-by-value mechanism.
Definition
True
Term
True/False: Encapsulation is the process of defining a class that has no public methods.
Definition
False
Term
True/False: Private methods are part of the interface of a class.
Definition
False
Term
True/False: A variable of class type does not store an object of that class.
Definition
True
Term
True/False: An equals method should return a boolean value.
Definition
True
Term
True/False: A method can change the value of a variable of a primitive type that is an argument to the method.
Definition
False
Term
True/False: A method can change the value of instance variables of an argument that is of a class type.
Definition
True
Term
What can you tell about the method surpriseMe in the code below?

int something;

something = surpriseMe();
Definition
It has no parameters but has a return value.
Term
Normally all instance variables are given the qualifier
Definition
private
Term
One benefit of encapsulation is
Definition
the implementation can be changed without changing programs that use the class
Term
When comparing two objects to see if they have the same contents, one should
Definition
define an equals method in the class and use it
Term
A ____ method is a method that can be invoked using the class name instead of an object name.
Definition
static
Term
The method used to convert from Character to char is ______
Definition
charValue
Term
The method used to convert from String to Float is _____
Definition
parseFloat
Term
A _____ is a simplified version of a method that is easily verified and is used for testing.
Definition
stub
Term
A _____ is a special kind of method used to initialize objects.
Definition
constructor
Term
Integer and Double are _____ classes
Definition
wrapper
Term
A constructor with no parameters is called a _____ constructor
Definition
default
Term
What will happen if a program uses an array index that is out of bounds?
Definition
The program will compile but Java will give an error message when the program runs.
Term
Which statement best describes an array of 10 elements where the elements are of class String?
Definition
The array will be created with the elements equal to null.
Term
The highest index that can be used with an array
Definition
is the number of elements in the array minus one
Term
The lowest index that can be used with an array
Definition
is zero
Term
True/False: Arrays in Java are objects
Definition
True
Term
True/False: The first element in an array is accessed using zero as an index.
Definition
True
Term
True/False: You can change the size of an array by assigning a new value to the length instance variable.
Definition
False
Term
True/False: The size of an array in Java is determined when the program is compiled.
Definition
False
Term
True/False: In a two-dimensional array, all of the rows must have the same number of elements.
Definition
False
Term
True/False: An accessor method that returns an array should return a copy of an instance variable array rather than the instance variable itself.
Definition
True
Term
True/False: If one element from an array is passed as a parameter to a method, then the called method can modify any element in the array.
Definition
False
Term
True/False: All data stored in an array must be the same type.
Definition
True
Term
True/False: Constructors have return type void.
Definition
False
Term
True/False: It is possible to have two methods in the same class that have the same name, the same number and types of arguments, but different return types.
Definition
False
Term
True/False: If you add at least one constructor to a class, no constructors will be automatically created for the class.
Definition
True
Term
The main job of the constructor method is to:
Definition
Initialize the object's instance variables
Supporting users have an ad free experience!