Midterm Flashcards
Computers process data under the control sequences of instructions called ______________.
computer programs
A computer consists of various devices referred to as ______________, such as the keyboard, screen, mouse, hard disks, memory, DVD drives, and processing units.
hardware
Data items processed by computers form a(n) ___________ that becomes larger and more complex in structure as we progress from the simplest data items (called “bits”) to richer data items, such as characters, fields, and so on.
data hierarchy
Computers can directly understand only their _________ language, which is composed of only 1s and 0s.
machine
The three types of computer programming languages discussed in this chapter are machine languages, ______________, and ____________.
assembly languages, high-level languages
Programs that translate high-level language programs into machine language are called ____________.
compilers
A(n) _____________ processor implements several processors on a single “microchip” – a dual-core processor has two CPUs and quad-core processor has four CPUs.
multi-core
Objects, or more precisely the __________ that objects come from, are essentially reusable software components.
classes
You send messages to an object. Each message is implemented as a method that tells a method of an object to perform its task.
call
A new class of objects can be created quickly and conveniently by ___________; the new class absorbs the characteristics of an existing class, possibly customizing them and adding unique characteristics of their own.
inheritance
To create the best solutions, you should follow a detailed analysis process for determining your project’s __________ (i.e., defining what the system is supposed to do) and developing a design that satisfies them (i.e., deciding how the system should do it).
requirements
Visual C# is __________ driven. You’ll write programs that respond to mouse clicks, keystrokes, timer expirations and –new in Visual C# 2012– touches and finger swipes.
event
Microsoft’s Visual C# is a(n) __________ programming language – in addition to writing program statements to build portions of your apps, you’ll also use Visual Studio’s graphical user interface (GUI) to conveniently drag and drop predefined objects like buttons and textboxes into place on your screen, and label and resize them.
visual
C++ provides several features that “spruce up” the C language, but more important, it provides capabilities for __________-oriented programming.
object
A key goal of Java is to be able to write programs that will urn on a great variety of computer systems and computer-control devices. This is sometimes called _______________.
write once, run anywhere
The _______________ executes .NET programs.
Common Language Runtime (CLR) of the .NET Framework
The CLR provides various services to ___________ code, such as integrating software components written in different .NET languages, error handling between such components, enhanced security and more.
managed
The ability of a program to run without modification across multiple platforms is known as platform _______________.
independence
Visual Studio is a(n) _________ in which C# programs are developed.
IDE
The new Windows 8 look-and-feel features a Start screen with _________ that represent each app, is similar to that of the Windows Phone – a Microsoft operating systems for smartphones.
tiles
Windows 8 apps feature a(n) _____________ window; there’s no longer a border around the window with the typical interface elements such as title bars and menus.
chromeless
You can sell your own Windows Phone apps in the ___________.
Windows Phone Marketplace
You can test your phone apps on the Windows Phone ____________ that Microsoft provides with the Windows Phone SDK (software developer kit).
Emulator
T or F: Software objects model both abstract and real-world things.
True
T or F: The most popular database model is the RELATIONAL DATABASE in which data is stored in simple TABLES. A table includes RECORDS and FIELDS.
True
T or F: A database is a collection of data that’s organized for easy access an manipulation.
True
T or F: Secondary storage data takes much longer to access than data in primary memory, but the cost per unit of secondary storage is much higher than that of primary memory.
False: The cost per unit of secondary storage is much lower than that or primary memory.
T or F: High-Level languages allow you to write instructions that look almost like everyday English and contain commonly used mathematical expressions.
True
T or F: An object has attributes that it carries along as it’s used in a program
True
T or F: The Transmission Control Protocol (TCP) ensures that messages, consisting of sequentially numbered pieces called bytes, were properly routed from sender to receiver, arrived intact and were assembled in the correct order.
False: Packets – not bytes
T or F: The information-carrying capacity of communications lines on the Internet has increased tremendously, while hardware costs have increased.
False: Hardware costs have decreased.
T or F: You can build web-based applications with C# and Microsoft’s ASP.NET technology.
True
T or F: JAVA has become the key programming language for the Mac OS X desktop operating system and all iOS-based devices, such as iPods, iPhones, and iPads.
False: The language is Objective-C, not JAVA
T or F: Microsoft’s ASP.WEB technology is used to create web apps.
False: It’s ASP.NET technology
T or F: Microsoft’s Windows operating system is the most widely used desktop operating system worldwide.
True
T or F: Windows 8 is designed for resource-constrained devices that have less memory and processor power than desktop computers, and limited battery life.
False: Windows Phone 8 is designed for resource-constrained devices.
T or F: Visual C# 2012 also can be used to develop Windows Phone 8 apps. Visual C# 2012 is sure to become even more popular as the demand for Windows Phones increases.
True
Arrange these byte measurements in order from smallest to largest: terabyte, megabyte, petabyte, gigabyte, and kilobyte.
kilobyte, megabyte, gigabyte, terabyte, petabyte
Describe the two-step translation process for preparing you C# code to execute on your particular computer.
C# code is first compiled into MSIL and placed in an executable file. When the app executes, another compiler called the JIT (just-in-time) compiler in the CLR translates the MSIL in the executable file into machine-language code (for a particular platform)
Why might Windows terminate a suspended app?
To free up memory for executing other apps.
A(n) __________ begins the body of every method and a(n) ________ ends the body of every method.
left brace ({), right brace (})
Most statements end with a(n) _____________.
semicolon (;)
The ____________ statement is used to make decisions.
if
___________ begins a single-line comment.
//
____________, ____________, and _____________ are called whitespace characters. Newline characters are also considered whitespace characters.
Blank lines, spaces characters, tab characters
_______________ are reserved for use by C#.
Keywords
C# apps begin execution at method _____________.
Main
Methods ______________ and _____________ display information in the console window.
Console.WriteLine and Console.Write
T or F: Comments cause the to display the text after the // on the screen when the app executes.
False: Comments do not cause any action to be performed with the app executes. They’re used to document apps and improve their readability.
T or F: C# considers the variable number and NuMbEr to be identical.
False: C# is case sensitive, so these variables are distinct.
T or F: The remainder operator (%) can only be used with integer operands.
False: The remainder operator also can be used with noninteger operands in C#.
T or F: The arithmetic operators *,/,%,+, and - all have the same level of precedence.
False: The operators *,/, and % are the same level of precedence, and the operators + and - are on a lower level of precedence.
Declare variables c, thisIsAVariable, q76354, and number to be of type int.
int c, thisIsAVariable, q76354, number;
OR
int c;
int thisIsAVariable;
int q76354;
int number;
Prompt the user to enter an integer.
Console.Write(“Enter an integer: “);
Input an integer and assign the result to int variable value.
int value = Convert.ToInt32(Console.ReadLine());
If the variable number is not equal to 7, display “The variable number is not equal to 7”.
if (number != 7)
Console.WriteLine(“The variable number is not equal to 7”);
Display “This is a C# app” on one line in the console window.
Console.WriteLine(“This is a C# app”);
Display “This is a C# app” on two lines in the console window. The first line should end with C#. Use method Console.WriteLine.
Console.WriteLine(“This is a C#\napp”);
Display “This is a C# app” on two lines in the console window. The first line should end with C#. Use method Console.WriteLine and two format items.
Console.WrtieLine(“{0}\n{1}, “This is a C#”, “app”);
FIND THE ERROR:
if (c > 7);
Console.WriteLine(“c is less than 7”);
ERROR: Semicolon after the right parenthesis of the condition(c < 7) in the if statement.
CORRECTION: Remove the semicolon after the right parenthesis. [NOTE: With the semicolon, the output statement executes regardless of whether the condition in the if is true.]
FIND THE ERROR:
if (c => 7)
Console.WriteLine(“c is equal to or greater than 7:);
ERROR: The relational operator => is incorrect.
CORRECTION: Change => to >=.
State that an app will calculate the product of three integers.
//Calculating the product of three integers.
Declare the variables x, y, z and result to be of type int.
int x, y, z, and result;
OR
int x;
int y;
int z;
int result;
Prompt the user to enter the first integer.
Console.WriteLine(“Enter first integer: “);
Read the first integer from the user and store it to variable x.
x = Convert.ToInt32(“Console.ReadLine());
Prompt the user to enter the second integer.
Console.WriteLine(“Enter second integer: “);
Read the second integer from the user and store it to variable y.
y = Convert.ToInt32(Console.ReadLine());
Prompt the user to enter the third integer.
Console.WriteLine(“Enter third integer: );
Read the third integer from the user and store it to variable z.
z = Convert.ToInt32(Console.ReadLine());
Compute the product of the three integers contained in variables x, y, and z, and assign the result to the variable result.
result = x y z;
Display the message “Product is”, followed by the value of the variable result.
Console.WriteLine(“Product is {0}”, result);
A house is to a blueprint as a(n) ___________ is to a class.
object
Every class declaration contains keyword __________ followed immediately by the class’s name.
class
Operator _________ creates an object of the class specified to the right of the keyword.
new
Each parameter must specify both a(n) __________ and a(n) _________.
type, name
By default, classes that are not explicitly declared in a namespace are implicitly placed in the ___________.
global namespace
When each object of a class maintains its own copy of an attribute , the field that represents the attribute is known as __________.
instance variable
C# provides three simple types for storing real numbers – _____________, ______________, and ____________.
float, double, decimal
Variables of type double represent ______________.
double-precision
Convert method ____________ returns a decimal value.
ToDecimal
Keyword public is a(n) ____________.
access modifier
Return type __________ indicates that a method will not return any information when it completes its task.
void
Console method ___________ reads characters until a neline character is encountered, the returns those characters (not including the newline) as a string.
ReadLine
A(n) ____________ is not required if you always refer to a class with its fully qualified class name.
using directive
Variables of type float represent ___________ floating-point numbers.
single-precision
The format specifier _________ is used to display values in a monetary format.
c
Types are either _________ types or ________ types.
value, reference
For a(n) __________, the compiler automatically generates a private instance variable and set and get accessors.
auto-implemented property
T or F: By convention, method names begin with a lowercase first letter and all subsequent words in the name begin with a capital first letter
False: By convention, method names begin with an uppercase first letter and all subsequent words in the name begin with an uppercase first letter.
T or F: A property’s get accessor enables a client to modify the value of the instance variable associated with the property.
False: A property’s get accessor enables a client to retrieve the value of the instance variable associated with the property. A property’s set accessor enables a client to modify the value of the instance variable associated with the property.
T or F: A using directive is not required when one class in a namespace uses another in the same namespace.
True
T or F: Empty parenthesis following a method name in a method declaration indicate that the method does not require any parameter to perform its task.
True
T or F: After defining a property, you can use it the same way you use a method, but with empty parentheses, because no arguments are passed to a property.
False: After defining a property, you can use it the same way you use a variable.
T or F: Variables or methods declared with access modifier private are accessible only to members of the class in which they’re declared.
True
T or F: Variables declared in the body of a particular method are known as instance variables and can be used in all methods of the class.
False: Such variables are called local variables and can be used only in the method in which they’re declared.
T or F: A property declaration must contain both a get accessor and a set accessor.
False: A property declaration can contain a get accessor, a set accessor or both.
T or F: The body of any method or property is delimited by left and right braces.
True
T or F: Local variables are initialized by default.
False: Instance variables are initialized by default.
T or F: Reference-type instance variables are initialozed by default to the value null.
True
T or F: Any class that contains public static void Main(string[ ] args) can be used to execute an app.
True
T or F: The number of arguments in the method call must match the number of required parameters in the method declaration’s parameter list.
True
T or F: Real number values that appear in source code are known as floating-point literals and are of type float by default.
False: Such literals are of type double by default.
What is the difference between a local variable and an instance variable.
Local variable: declared in the body of a method and can be used only in the method in which it’s declared.
Instance variable: declared in a class, but not in the body of any of the class’s members. Every object (instance) of a class has a separate copy of the class’s instance variables. They are accessible to all members of the class.
Explain the purpose of a method parameter. What is the difference between a parameter and an argument.
A parameter represents additional information that a method requires to perform its task. Each parameter required by a method is specified in the method’s declaration. An argument is the actual value that’s passed to a method parameter when a method is called.
All apps can be written in terms of three types of control structures: ________________________, ____________________________, and ________________________.
sequence, selection, repetition
The ______________________ statement is used to execute once action when a condition is true and another when the condition is false.
if….else
Repeating a set of instructions a specific number of times is called ____________________ repetition.
counter-controlled (or definite)
When it’s not known in advance how many times a set of statements will be repeated, a(n) ________________ value can be used to terminate the repetition.
sentinel, signal, flag, or dummy
The _________________ structure is built into C#–by default, statements execute in the order they appear.
sequence
Instance variables of type int are given the value __________ by default.
0
C# is a(n) _______________ language- it requires all variables to have a type.
strongly typed
If the increment operator is _____________________ to a variable, the variable is incremented by 1 and its new value is used in the expression.
prefixed
T or F: An algorithm is a procedure for solving a problem in terms of the actions to execute and the order in which these actions execute.
True
T or F: A set of statements contained within a pair of parenthesis is called a block.
False: A set of statements contained within a pair of braces ({ and }) is called a block.
T or F: A selection statement specifies that an action is to be repeated while some condition remains true.
False: A repetition statement specifies that an action is to be repeated while some condition remains true. A selection statement determines whether an action is performed based on the truth of falsity of a condition.
T or F: A nested control statement appears in the body of another control statement.
True
T or F: C# provides the arithmetic compound assignment operators +=, -=, *=, /= and %= for abbreviating assignment expressions.
True
T or F: Specifying the order in which statements (actions) execute in an app is called program control.
True
T or F: The unary cast operator (double) creates a temporary integer copy of its operand.
False: The unary cast operator (double) creates a temporary floating-point copy of its operand.
T or F: Instance variables of type bool are given the value true by default.
False: Instance variables of type bool are given the value false by default.
T or F: Pseudocode helps you think out an app before attempting to write it in a programming language.
True
Write four different C# statements that each add 1 to int variable x.
x = x + 1;
x += 1;
++x;
x++;
Assign the sum of x and y to z, and increment x by 1 with ++. Use only one statement and ensure that the original value of x is used in the statement.
z = x++ y;
Test whether variable count is greater than 10. If it is, display “Count is greater than 10”.
if (count > 10)
Console.WriteLine(“Count is greater than 10”);
Decrement the variable x by 1, then subtract it from the variable total. Use only one statement.
total -= –x;
Calculate the remainder after q is divided by divisor, and assign the result to q. Write this statement in two different ways.
q %= divisor;
q = q % divisor;
Declare variable sum to be of type int.
int sum;
Declare variable x to be of type int.
int x;
Assign 1 to variable x.
x = 1;
Assign 0 to variable sum.
sum = 0;
Add variable x to variable sum, and assign the result to variable sum.
sum += x;
or
sum = sum + x;
Display “The sum is: “ followed by the value of the variable sum.
Console.WriteLine(“The sum is: {0}”, sum);
Identify and correct the errors:
while (c <= 5)
{
product *= c;
++c;
ERROR: The closing right brace of the while statement’s body is missing.
CORRECTION: Add a closing right brace after the statement ++c;
Identify and correct the errors:
if (gender == 1)
Console.WriteLine(“Woman”);
else;
Console.WriteLine(“Man”);
ERROR: The semicolon after else results in a logic error. The second output statement will always execute.
CORRECTION: Remove the semicolon after else.
What is wrong with the following while statement?
while (z >= 0 )
sum += z;
The value of the variable z is never changed in the while statement. Therefore, an infinite loop occurs if the loop-continuation condition (z >= 0) is initially true. To prevent an infinite loop, z must be decremented so that it eventually becomes less than 0.
Typically, __________________ statements are used for counter-controlled repetition and _______________________ statements are used for sentinel-controlled repetition.
for, while
The do…while statement tests the loop-continuation condition ____________________ executing the loop’s body; therefore, the body always executes at least once.
after
The _____________ statement selects among multiple actions based on the possible values of an integer variable or expression.
switch
The ______________ statement, when executed in a repetition statement, skips the remaining statements in the loop body and proceeds with the next iteration of the loop.
continue
The ____________ operator can be used to ensure that two conditions are both true before choosing a certain path of execution.
&& (conditional AND) or & (boolean logical AND)
If the loop-continuation condition in a for header is initially _________________, the for statement’s body does not execute.
false
Methods that perform common tasks and cannot be called on objects are called _____________ methods.
static
T or F: The default label is required in the switch selection statement.
False: The default label is optional. If no default action is needed, then there’s no need for a default label
T or F: The break statement is required in ever case of a switch statement.
False: You could terminate the case with other statements, such as a return.
T or F: The expression ((x > y) && (a < b)) is true if either (x > y) is true OR ( a < b) is true.
False: Both of the relational expressions must be true for this entire expression to be true when using the && operator.
T or F: An expression containing the || operator is true if either or both of its operands are true.
True
T or F: The integer after the comma (,) in a format item (e.g {0, 4}) indicates the field width of the displayed string.
True
T or F: To test for a range of values in a switch statement, use a hyphen (-) between the start and end values of the range in a case label.
False: The switch statement does not provide a mechanism for testing ranges of values, so you must list every value too test in a separate case label.
T or F: Listing cases consecutively with no statements between them enables the cases to perform the same set of statements.
True