C# midterm

Ace your homework & exams now with Quizwiz!

What is Substring() for?

extracting a portion of a string from a starting point for a specific length

*When you declare an object, what are the bool fields initialized to?* a. true b. '\u0000' c. false d. null

false

*What type of statement can be used to make a single-alternative decision?* a. fork b. if c. switch d. if-else

if

How would condition ? expression1 : expression2 be written as an if-else?

if (condition) expression1; else expression2;

*In a situation where you want to perform one action when a Boolean expression evaluates as true and an alternate action when it evaluates as false, otherwise known as a dual-alternative decision, what sort of statement should you use?* a. if-else b. switch c. fork d. if

if-else

an _____ conversion or cast is the automatic transformation that occurs when a value is assigned to a type with higher precedence

implicit

*When using arithmetic operations with operands of dissimilar types, an automatic conversion of nonconforming operands to a unifying type occurs. What is this conversion process called?* a. explicit cast b. level cast c. implicit cast d. manual cast

implicit cast

Where do you code an enumeration (enum)?

in a class, outside of any methods (often before Main)

*A loop that is controlled by user input rather than altered by arithmetic is known as what type of loop?* a. indefinite b. infinite c. sentinel d. definite

indefinite

An _______ loop does not have a predetermined number of iterations

indefinite

A subscript is also called an ______

index

What does the void keyword mean?

indicates the method doesn't return any value

What does the static keyword mean?

indicates the method will be executed through a class not an object

An ____ loop theoretically never ends

infinite

A ______ string is used exactly as entered

literal

A _____ _____ _____ determines whether the loop execution will continue

loop control variable

*What technique can be used to combine two different loops into one?* a. short-circuiting loop b. loop accumulation c. pretesting loop d. loop fusion

loop fusion

*Internally, computers are constructed from circuitry that consists of small on/off switches. What is the most basic circuitry-level language that computers use to control the operation of those switches called?* a. syntax b. machine language c. compiler d. program

machine language

__________ is the most basic circuitry-level language

machine language

Multidimensional arrays require ____ subscripts to access array elements

multiple

*What operator is used for the purpose of creating objects in C#?* a. reserve b. save c. initialize d. new

new

_______ are the values that operators use in expressions

operands

*When using a nested loop, what should always be thought of as the all-encompassing loop?* a. for loop b. inner loop c. outer loop d. while loop

outer loop

______ arrays have the same number of elements as another array and corresponding data

parallel

*What type of array has the same number of elements and corresponding data with another array?* a. parallel array b. shared array c. twin array d. shadow array

parallel array

to ____ an item is to break it into component parts

parse

("I am {0} years old", age) uses _________

placeholder method

*What type of loop is one in which the loop control variable is tested after the loop body executes?* a. intest b. posttest c. pretest d. fortest

posttest

do is an example of a ______ loop

posttest

a ____ ____ evaluation is the feature where parts of an AND or OR expression are evaluated only as far as needed to determine whether the entire expression is true or false

short circuit

*The expressions in each part of an AND or OR expression are evaluated only as much as necessary to determine whether the entire expression is true or false. What type of evaluation is this?* a. short-circuit b. while c. stopwatch d. loop

short-circuit

*An array that you can picture as a column of values, and whose elements you can access using a single subscript, is what type of array?* a. jagged b. single-dimensional c. rectangular d. two-dimensional

single-dimensional

*An array that you can picture as a column of values, and whose elements you can access using a single subscript, is what type of array?* a. single-dimensional b. jagged c. rectangular d. two-dimensional

single-dimensional

t/f - C# was developed as an object-oriented and component-oriented language.

true

t/f - Convert and Parse() are practically the same thing

true

t/f - The equal sign (=) is the C# assignment operator.

true

t/f - The power of arrays becomes apparent when you use subscripts that are variables rather than constant values.

true

t/f - When loop structures are nested, the inner loop must be entirely contained within the outer loop; loops can never overlap.

true

t/f - You can combine as many AND and OR operators in an expression as needed.

true

t/f - a loop's performance can be improved by declaring temporary variables outside of it

true

t/f - conditional && and || operators use short circuit evaluation

true

t/f - to use BinarySearch() the array must be organized in ascending order

true

____ ______ arrays have 2+ columns of values for each row

two dimensional

_____ operators are operators with one operand (like ++ or --)

unary

A namespace is declared with _____

using

A _______ identifier has an @ prefix

verbatim

*An identifier that is prefixed with an @ and allows you to use code written in other languages that do not have the same set of reserved keywords is known by what name?* a. a commenting identifier b. a translating identifier c. a verbatim identifier d. a language identifier

verbatim identifier

*What character(s) function as the non-conditional Boolean logical inclusive OR operator?* a. | b. && c. || d. &

|

What are the 5 arithmetic operators?

% + - * /

*What character(s) function as the non-conditional Boolean logical AND operator in the C# programming language?* a. && b. & c. || d. |

&

*What character(s) do you use to make a conditional AND operator within a C# program?* a. || b. && c. & d. |

&&

Which takes precedence && or ||?

&&

How would you explicitly cast the variable myMoney from an int to a double?

(double) myMoney

If BinarySearch() doesn't find the number in the array it will return ___

-1

*When you declare an object, what are the numeric fields initialized to?* a. false b. 0 c. null d. '\u0000'

0

To accumulate a total in a loop, the variable used to hold a total must be set to _

0

*What will be the highest subscript value possible for an array with 15 elements?*

14

How many decimals can a double have?

15 or 16

Dual alternative decision have __ possible outcomes

2

How many bytes does a char have?

2

How many bytes does an int have?

4

How many decimals can a float have?

7

*When an array is initialized with the double keyword, how large is each element of the array?* a. 1 byte b. 8 bits c. 8 bytes d. 8 megabytes

8 bytes

Which is correct: <= or =< ?

<=

*What character(s) are used to form the ternary conditional operator in C#?* a. ?: b. ?; c. ? d. !:

?:

*Navigation through an entire array using a for or while loop can be done by varying a subscript from 0 to what value?* a. Array.Length + 1 b. Array.Length c. Array.Length - 1 d. Array.Length - 2

Array.Length - 1

*In order to use the Sort() method, what must the array name be passed to?* a. List.Sort( ) b. Sort.Sort( ) c. Collections.Sort( ) d. Array.Sort( )

Array.Sort( )

*What method can be used to find the array position of a requested value in an array by repeatedly splitting the list of objects until a match is found, but only if the array is sorted in ascending order?* a. Sort( ) b. IndexOf( ) c. Reverse( ) d. BinarySearch( )

BinarySearch( )

*What statement regarding the C# programming language is accurate?* a. C# was developed as a procedural language. b. C# is modeled after the COBOL programming language. c. C# only allows specific pieces of data to be treated as objects. d. C# provides constructs for creating components with properties, methods, and events.

C# provides constructs for creating components with properties, methods, and events

*When designing a flowchart for assisting in the coding process, what is a parallelogram typically used to represent?* a. They usually represent decision blocks. b. They usually represent input and output statements. c. They usually represent errors that should occur when provided invalid data. d. They usually represent a declaration of a value.

Input & output statements

*How can the Array methods such as BinarySearch() and Sort() be used without constantly referencing the Array class name?* a. Issue a using static System.Array(); statement. b. Issue a using class Array; statement. c. Add include Array.*; to the beginning of your program. d. Place a copy of the System.dll file in your project.

Issue a using static System.Array(); statement

The _ _ _ compiler translates intermediate code into executable code

JIT (just in time)

What is encapsulation?

Packaging an object's attributes and methods into a cohesive unit that can be used as an undivided entity

*What programming style capitalizes the first letter of all new words in an identifier, including the first one?* a. OOP casing b. upper casing c. camel casing d. Pascal casing

Pascal casing

How do you declare a random generator?

Random ran = new Random();

*What method does not sort array elements, but rather rearranges their positions to the opposite order?* a. BinarySearch( ) b. Reverse( ) c. Order( ) d. Opposite( )

Reverse( )

What is K&R style indention?

What I do with putting the curly brace at the end of the line instead of on its own line Like if (number <5) {

What is polymorphism?

When two different objects respond to the same method in different ways

*When writing C# code, how do you indicate a namespace?* a. You must specify the namespace by using the namespace keyword, followed by the namespace b. You must utilize the using clause, or using directive, by specifying using, followed by the namespace c. You must use create a file called "namespace", and include all namespace code in this file. Then, the namespace can be used by name in your program d. You must use the declare namespace keywords, followed by the namespace.

You must utilize the using clause, or using directive, by specifying using, followed by the namespace

*What characters indicate a subscript?*

[ ]

*What can be used to distinguish each element from the others in an array?* a. an element ID b. an element operator c. a subscript d. an object location

a subscript

*Totals that are summed one at a time in a loop are known as what type of totals?* a. incremented b. accumulated c. decremented d. derived

accumulated

lexically means ____

alphabetically

*An assignment that is made when a variable is declared is known as what?* a. An allocation of the variable b. An initialization of the variable c. A definition of the variable d. An assignment to the variable

an initialization of the variable

*What is any single execution of a loop referred to as?* a. A lap of the loop b. An iteration of the loop c. A round in the loop d. A path through the loop

an iteration of the loop

________ classes contain a Main() method & are executable programs

application

_____________ specifies the order that a sequence of operations with the same precedence are evaluated

associativity

implicit means _____

automatic

*What type of arithmetic operator has one argument to the left and another argument to the right of the operator?* a. binary b. unary c. composite d. complex

binary

a + b is a _______ operator

binary

_____ operators manipulate individual bits of values

bitwise

*Encapsulation is similar to using a device without regard for the internal mechanisms. What is the common term for this type of device?* a. interface b. blue box c. black box d. object

black box

A ________ is a device used without regard for its internal mechanisms

black box

A ____ is a collection of statements in curly braces {}

block

*After executing your GUI program, you realize that your code has created an infinite loop. How can you break free of the loop in your GUI program?* a. Use Ctrl + Break b. Use Ctrl + C c. Close the Frame that hosts the application d. Close the IDE

close the frame that hosts the application

*What type of expression has a Boolean value as a result?* a. comparison b. decrement c. unifying d. assignment

comparison

A _________ translates a high level language into machine code

compiler

*What operator is used as an abbreviated version of the if-else statement, and requires three expressions separated with a question mark and a colon?* a. conditional b. switch c. NOT d. XOR

conditional

A _____ operator is a shorter version of an if-else statement, using 3 statements separated by a ? and :

conditional

What is.... condition ? expression1 : expression2

conditional operator

Which programs contain more coded decisions: event-driven or console-based?

console-based

*The if expression that precedes a block in a decision structure is known as what type of statement?* a. K & R b. sequence c. control d. conditional

control

A ______ statement determines whether the next block executes or not

control

A ______ is a set of rules that determines how culturally dependent values like money & dates are formatted

culture

*What type of structure involves choosing between alternative courses of action based on some value within a program?* a. sequence b. decision c. literal d. fixed

decision

In a ______ structure, choosing between alternatives determines the course of action

decision

*What is the name for a series of characters used to control the appearance of text output?* a. A declared namespace b. A set placeholder c. Carefully placed whitespace d. A defined format string

defined format string

A ______ loop has a predetermined number of iterations

definite

an ______ ________ is a nonprinting character like a tab

escape sequence (like \t)

an ____ cast purposefully assigns a value to a different data type

explicit

*You are performing an arithmetic operation and have placed the desired result type in parentheses followed by a variable to be cast with the result. What is this an example of?* a. explicit casting b. automatic casting c. intrinsic casting d. implicit casting

explicit casting

t/f - Array.Reverse() sorts the array in descending order

false

t/f - In C#, an array's elements are numbered beginning with 1.

false

t/f - Statements in a for loop body cannot be blocked.

false

t/f - a switch statement needs a default case

false

t/f - logical & and | operators use short circuit evaluation

false

t/f - someValue++ is an example of the use of the prefix increment operator.

false

t/f - you can accumulate totals with an uninitialized variable

false

What are the 3 floating-point data types?

float, double, decimal

*What type of loop allows you to indicate the starting value for the loop control variable, the test condition that controls loop entry, and the expression that alters the loop control variable, all in one convenient place?* a. repeat b. do c. for d. while

for

*What statement allows you to cycle through every array element without using a subscript?* a. for b. foreach c. do-while d. while

foreach

double myDouble; is an _________

initialization

int myInt = 2; is an _________

initialization

*An array subscript can be an expression, but only as long as the expression evaluates to what type?* a. float b. double c. boolean d. int

int

*What type of program specifically allows and accepts user input?* a. procedural program b. static program c. interactive program d. constant program

interactive program

An ________ language is the language into which source code statements are compiled

intermediate

"$I am {age} years old" uses _________

interpolation

*What is a garbage value in the C# programming language?* a. It is a variable that holds output text after it is displayed b. It is a variable that is assigned a value that has no purpose c. It is a variable that is used as a placeholder d. It is an unknown, unassigned value.

it is an unknown, unassigned value

*With the foreach statement, what is used to automatically hold each array value through each iteration of the loop?* a. index holder b. iteration variable c. iteration holder d. subscript holder

iteration variable

*What type of one-dimensional array contains another one-dimensional array in each element, with each array capable of being a different length?* a. jagged b. table c. rectangular d. matrix

jagged

______ arrays are arrays of arrays

jagged

while & for are examples of ______ loops

pretest

A _____ program is created by writing a series of steps or operations to manipulate values

procedural

*When running a program, an instruction to the user to enter data for the program to process is known by what term?* a. hint b. line c. cue d. prompt

prompt

explicit means ____

purposeful

*What type of array utilizes the same number of columns in each row?* a. vector b. linear c. list d. rectangular

rectangular

_______ arrays have the same number of columns in each row

rectangular

_______ is the area where a variable is known and can be used

scope

constants are created using _______ _____ like MY_NUMBER

screaming caps

In a ______ structure, one step follows another unconditionally

sequence

*What type of search is performed when each array element is examined in order?* a. range match b. sequential c. binary d. parallel

sequential

*Why do event-driven GUI programs sometimes require fewer coded loops than their counterpart console applications?* a. GUI programs have better loop performance and can benefit more from loop fusion. b. A GUI's properties removes the need for some loops. c. Some events are determined by the user's actions when the program is running. d. A GUI program can utilize loop nesting, while a console program cannot.

some events are determined by the user's actions when the program is running

*In the statement moneyString = someMoney.ToString("F3"), what is "F3" an example of?* a. literal constant b. named constant c. intrinsic type d. standard numeric format string

standard numeric format string

sum + total = total can also be written as ________

sum += total

*What kind of conditional operator requires three arguments: a test expression, and true and false result expressions?* a. ternary conditional operator b. enumeration conditional operator c. unary conditional operator d. binary conditional operator

ternary

*Given an array that has many possible matches of a search value, what is the most efficient strategy for placement of items?* a. The items should be sorted in ascending order b. The items should be randomly sorted c. The items should be sorted in descending order d. The items should be sorted with the most common items first

the items should be sorted with the most common items first


Related study sets

Real Estate Contracts and Agency

View Set

AP Euro Ch. 22 PRACTICE QUESTIONS

View Set