Fundamentals of Computer Science Exam 2
The ________ operator computes the remainder of division.
%
Comments
-Ignore everything from a // delimiter to the end of the line -Longer comments go in /* */
Names
-Must start with a letter or the underscore (_) character -Remaining characters must be letters, numbers, or underscores. -Cannot use other symbols such as ? or % or a space -Use camelCase -Case sensitive -Cannot use reserved words such as double or class -Variables start with lowercase, classes start with uppercase
Instance variables
-Stores the data of an object -A storage location present in each of the class
Assignments
-Use (=) to change the value of the variable
String positions are counted beginning with a ________.
0
The software development process
1. Understand the problem 2. Develop and describe an algorithm 3. Test the algorithm with different inputs 4. Translate the algorithm into Java 5. Compile and test your program
The binary equivalent of 117 is ________.(Make sure you include leading zeroes)
1110101
The value of x after these statements have executed is ________. int x = 3; x--; x++; x--;
2
After evaluating the following, the result would be ________. int x = 3; Math.sqrt(Math.pow(x,2));
3
The decimal equivalent of 00100110 is ________.
38
Algorithm
A sequence of steps that is unambiguous, executable, and terminating
Classes
A set of objects with the same behavior
Exception
A type of run time error that generates an error message from the Java virtual machine
a]variables are initialized to a default value, but you must initialize [b] variables.
A. Instance B. Local
The word "private" is a/n ________________ specifier.
Access
Object
An entity in your program that you can manipulate by calling one or more of its methods
The primitive type that has only two possible values is __________.
Boolean
You use a ________ to convert a value to a different type.
Cast
The constructor name is always the same name as the ______________.
Class
The java compiler translates source code into __________ files that contain instructions for the Java virtual machine.
Class
The fundamental building block of Java programs.
Classes
Use documentation ___________________ to describe the classes and public methods of your programs.
Comments
Used to help human readers understand your programs.
Comments
A ___________ error is a violation of the programming language rules that is detected by the compiler.
Compile-time
Method
Consists of a sequence of instructions that can access the data of an object
________________ set the initial data for objects.
Constructors
Secondary storage
Data storage that persists without electricity
Java has _________ primitive types.
Eight
The process of hiding implementation details while publishing an interface is called ____________.
Encapsulation
Data processing
Fetches data from external memory or devices, store data
To tell Java that a variable is a constant use the keyword ________.
Final
Information ________ makes it simpler for the implementor of a class to locate errors and change implementations.
Hiding
Use of an instance variable name in a method denotes the instance variable of the ___________ parameter.
Implicit
An object is a ______________________ of a class.
Instance
Each object of a class has its own set of ____________________ variables.
Instance
If both arguments of the / operator are integers, the result is a/n ________.
Integer
___________ variables are declared in the body of a method.
Local
Program control
Locates and executes program instructions; Carries out arithmetic operations
A run-time error is also called a _________ error.
Logic
Every java application contains a class with a __________ method.
Main
To find the square root of a number, use the ________ class. (capitalize if appropriate)
Math.sqrt()
The word "value" is the ________________ of the variable.
Name
What does CPU (Central processing unit) do?
Performs program control and data processing
Types of storage
Primary and secondary storage
A computer _________ executes a sequence of very basic instruction in rapid succession.
Program
A numeric computation overflows if the result falls outside the ________ for the numeric type.
Range
When a method exits, its local variables are ________________.
Removed
________ errors occur when an exact conversion between numbers is not possible.
Rounding
A _______ error causes a program to take an action that the programmer did not intend.
Run-time
What are the two most important benefits of the Java language?
Safety and portability
A ________ method does not operate on an object.
Static
Primary storage
Storage that needs to be supplied with power
Variable
Stores a value that you want to use later
A sequence of characters enclosed in quotation marks.
String
Peripherals
To interact with human users (e.g., display screen, speakers, printers, a keyboard, a mouse)
The word "int" is the ________________ of the variable.
Type
The escape sequence which mover your print to another line is ________.
\n
Types include...
int, double, string
Write the shorthand way to increment the variable x by 1.
x++