0% found this document useful (0 votes)
79 views16 pages

C. Sharp

This document contains a multiple choice quiz with questions about methods, arrays, and objects in C#. Some key points: - Methods can be used to break a program into smaller modular units and allow code reuse. Method components include the header, body, parameters, and return type. - Arrays provide a way to store and access multiple values of the same type. Arrays have elements with unique indexes, a length property, and can be initialized with a list. - Objects are stored using references rather than values. Reference variables point to objects in memory. The new operator allocates memory for new objects. Garbage collection removes unused objects.

Uploaded by

Easy Code
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views16 pages

C. Sharp

This document contains a multiple choice quiz with questions about methods, arrays, and objects in C#. Some key points: - Methods can be used to break a program into smaller modular units and allow code reuse. Method components include the header, body, parameters, and return type. - Arrays provide a way to store and access multiple values of the same type. Arrays have elements with unique indexes, a length property, and can be initialized with a list. - Objects are stored using references rather than values. Reference variables point to objects in memory. The new operator allocates memory for new objects. Garbage collection removes unused objects.

Uploaded by

Easy Code
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Chapter 6

Multiple Choice

1. In general terms, a program that is broken into smaller units of code, such as methods, is known as
a(n) __________.

a. object-oriented program

b. modularized program

c. procedural program

d. method-driven program

2. Writing the code to perform a task once and then reusing it each time you need to

perform the task is a benefit of using methods called __________.

a. code reuse

b. the single-use philosophy

c. method recycling

d. code reprocessing

3. When you call a(n) __________, it simply executes the statements it contains and

then terminates.

a. intrinsic method

b. empty method

c. logical method

d. void method

4. The __________, which appears at the beginning of a method definition, lists several

important things about the method, including the method’s name.

a. method title

b. method description

c. method header

d. method declaration

5. The __________ is a collection of statements enclosed inside a set of curly braces

that are performed when the method is executed.

a. method body
b. method designation

c. method code

d. method classification

6. The __________ is the memory address that is saved by the system when a method is

called and is the location to which the system should return after a method ends.

a. calling address

b. method address

c. return point

d. come back position

7. Programmers commonly use a technique known as __________ to break down an

algorithm into methods.

a. prototyping

b. method modeling

c. algorithm division

d. top–down design

8. Pieces of data that are sent into a method are known as __________.

a. arguments

b. references

c. method variables

d. data entries

9. A(n) __________ is a special variable that receives an argument when a method is called.

a. reference variable

b. argument variable

c. parameter variable

d. method variable

10. A __________ specifies which parameter an argument should be passed into.

a. named argument

b. special argument

c. constant argument
d. literal argument

11. When a(n)__________ is provided for a parameter, it becomes possible to call the

method without explicitly passing an argument into the parameter.

a. local argument

b. empty argument

c. default argument

d. expressional argument

12. When an argument is __________, only a copy of the argument’s value is passed into

the parameter variable.

a. a named constant

b. passed by association

c. passed by reference

d. passed by value

13. When you want a method to be able to change the value of a variable that is passed

to it as an argument, the variable must be __________.

a. passed by reference

b. a local variable

c. passed by value

d. a named constant

14. A __________ a special type of parameter variable that is useful for establishing

two-way communication between methods.

a. communication variable

b. reference parameter

c. method parameter

d. global variable

15. A(n) __________ can have an uninitialized value passed into it, but it must be set to

some value before the method it belongs to finishes executing.

a. input parameter

b. reference parameter
c. output parameter

d. default parameter

16. A method’s __________ is the type of value that the method returns.

a. data type

b. return type

c. value type

d. method type

True or False

1. Dividing a large problem into several smaller problems that are easily solved is

sometimes called divide and conquer. True

2. In a Pascal case name, the first character is always uppercase. True

3. If a method belongs to a class, then you must write a method’s definition inside

the class. True

4. The contents of variables and the values of expressions cannot be passed as arguments. False

5. You do not have to write the data type for each parameter variable that is declared

in a parameter list if they are all of the same data type. False

6. An output parameter works like a by value parameter. False

7. A value-returning method must contain a return statement. True

8. A Boolean method returns either yes or no. False

Short answer

1. What do you call a method that executes the statements it contains and then returns

a value back to the statement that called it?

value-returning method

2. What is the standard naming convention used among C# programmers for method

names? Why?

Pascal Case (because it makes the method name different from fields and variable names)

3. What is another name for the top-down design process?

Step wise refinement

4. What is a parameter list?


The set of parameter variables that are declared within method header parenthesis.

5. How do you specify a named argument?

parameterName.value

6. How are output parameters different from reference parameters?

Output: the value of an argument need not to be set before passing it to output parameter.

Value of the output parameter must be set to some value before completing the execution.

Output parameter must be declared by using the keyword out before data type of parameter
variable.

Reference: The value of an argument must be set before passing it to reference parameter

Value of the reference parameter should not be set to some value before completing the
execution

7. How is a value-returning method like a void method? How is it different?

Similar: It includes set of statements that does a specific task. Whenever the method needs to be
executed,

8. Can Boolean methods be used to modularize input validation? Why or why not?

Yes they can be used if a form contains many Textbox controls, then input validation needs nested
and multiple if statements

Chapter 7

Multiple Choice

1. The memory that is allocated for a __________ variable is the actual location that

will hold any value that is assigned to that variable.

a. reference type

b. general type

c. value type

d. framework type

2. A variable that is used to reference an object is commonly called a(n) __________.


a. reference variable

b. resource variable

c. object variable

d. component variable

3. When you want to work with an object, you use a variable that holds a special value

known as a(n) __________ to link the variable to the object.

a. union

b. reference

c. object linker

d. data coupling

4. The __________ creates an object in memory and returns a reference to that object.

a. = operator

b. object allocator

c. reference variable

d. new operator

5. A(n) __________ is an object that can hold a group of values that are all of the same

data type.

a. array

b. collection

c. container

d. set

6. The __________ indicates the number of values that the array should be able to

hold.

a. allocation limit

b. size declarator

c. data type

d. compiler

7. The storage locations in an array are known as __________.

a. elements
b. sectors

c. pages

d. blocks

8. Each element in an array is assigned a unique number known as a(n) __________.

a. element identifier

b. subscript

c. index

d. sequencer

9. When you create an array, you can optionally initialize it with a group of values

called a(n) __________.

a. default value group

b. initialization list

c. defined set

d. value list

10. In C#, all arrays have a __________ that is set to the number of elements in the

array.

a. Limit property

b. Size property

c. Length property

d. Maximum property

11. A(n) __________ occurs when a loop iterates one time too many or one time too

few.

a. general error

b. logic error

c. loop count error

d. off-by-one error

12. C# provides a special loop that, in many circumstances, simplifies array processing.

It is known as the __________.

a. for loop
b. foreach loop

c. while loop

d. do-while loop

13. The foreach loop is designed to work with a temporary, read-only variable that is

known as the __________.

a. element variable

b. loop variable

c. index variable

d. iteration variable

14. __________ is a process that periodically runs, removing all unreferenced objects

from memory.

a. Systematic reallocation

b. Memory cleanup

c. Garbage collection

d. Object maintenance

15. Various techniques known as __________ have been developed to locate a specific

item in a larger collection of data, such as an array.

a. seek functions

b. request methods

c. traversal procedures

d. search algorithms

16. The __________ uses a loop to step through an array, starting with the first element,

searching for an item.

a. sequential search algorithm

b. top-down method

c. ascending search algorithm

d. basic search function

17. A(n) __________ is a type of assignment operation that copies a reference to an

array and not the contents of the array.


a. object copy

b. reference copy

c. double reference

d. parallel copy

18. The __________ is a clever algorithm that is much more efficient than the sequential

search.

a. linear search

b. bubble sort

c. binary search

d. selection sort

19. A __________ is similar to a two-dimensional array, but the rows can have different

numbers of columns.

a. one-dimensional array

b. columnar array

c. jagged array

d. split row array

20. The .NET Framework provides a class named __________, which can be used for

storing and retrieving items.

a. Matrix

b. Database

c. Container

d. List

True or False

1. When you are working with a value type, you are using a variable that holds a piece

of data. TRUE

2. Reference variables can be used only to reference objects TRUE

3. Individual variables are well suited for storing and processing lists of data. FALSE

4. Arrays are reference type objects. TRUE

5. You can store a mixture of data types in an array. FALSE


6. When you create a numeric array in C#, its elements are set to the value 0 by default. TRUE

7. The subscript of the last element will always be one less than the array’s Length

property. TRUE

8. You use the == operator to compare two array reference variables and determine

whether the arrays are equal. FALSE

9. A jagged array is similar to a two-dimensional array, but the rows in a jagged array

can have different numbers of columns. TRUE

10. When you create a List object, you do not have to know the number of items that

you intend to store in it. TRUE

Short answer

1. How much memory is allocated by the compiler when you declare a value type
variable?

The compiler sets aside, or allocates, a chunk of memory that is big enough for that variable.

2. What type of variable is needed to work with an object in code?

A reference type variable

3. What two steps are typically required for creating a reference type object?

1. Declare a reference variable.


2. Create the object and associate it with the reference variable.

4. Are variables well suited for processing lists of data? Why or why not?

No. Because variables hold only a single value, they can be cumbersome in programs that process lists
of data.

5. What value is returned by the Length property of an array?

The number of elements in the array.

6. What can cause an off-by-one error when working with an array?

When a loop iterates one time too many or one time too few.

7. How do you keep track of elements that contain data in a partially filled array?

A partially filled array is normally used with an accompanying integer variable that holds the number
of items that are actually stored in the array.
8. Briefly describe the selection sort algorithm.

The smallest value in the array is located and moved to element 0. Then the next smallest value is
located and moved to element 1. This process continues until all of the elements have been placed in
their proper order.

9. How is the binary search more efficient that the sequential search algorithm?

The portion of the array being searched is divided in half each time the loop fails to located the search
value.

10. What advantages does a List have over an array?

1. When you create a List object, you do not have to know the number of items that you intend
to store in it.
2. A list object automatically expands as items are added to it.
3. In addiction to adding items to a List, you can removed items as well.
4. A list object automatically shrinks as items are removed from it.

Chapter 8

Multiple Choice

1. In C#, __________ are enclosed in single quotation marks.

a. strings

b. enumerators

c. tokens

d. character literals

2. The char data type provides the __________ for converting the case of a character.

a. Lowercase and Uppercase methods

b. To Lower and To Upper methods

c. Is Digit and Is Letter methods

d. Is Whitespace and Is Punctuation methods

3. A string within a string is called a(n) __________.

a. character

b. inner string

c. substring
d. thread

4. The __________ of a string object allow you to search for substrings.

a. Trim Start and Trim End methods

b. IndexOf and LastIndexOf methods

c. Is Whitespace and Is Punctuation methods

d. Contains, Starts With, and Ends With methods

5. When you want to know the position of the substring, you can use one of the

__________ of a string object.

a. TrimStart or TrimEnd methods

b. IndexOf or LastIndexOf methods

c. ToLower or ToUpper methods

d. StartsWith or EndsWith methods

6. The __________ of a string object can be used to retrieve a specific set of characters from a string.

a. Substring method

b. IndexOf method

c. Trim Start and Trim End methods

d. Starts With and Ends With methods

7. __________ are spaces that appear at the beginning of a string.

a. Leading spaces

b. Primary spaces

c. Starting spaces

d. Empty spaces

8. __________ are spaces that appear at the end of a string.

a. Blank spaces

b. Secondary spaces

c. Ending spaces

d. Trailing spaces

9. A series of words or other items of data contained in a string and separated by

spaces or other characters are known as __________.


a. substrings

b. elements

c. characters

d. tokens

10. The character that separates tokens is known as a __________.

a. partition

b. literal

c. delimiter

d. symbol

11. The process of breaking a string into tokens is known as __________.

a. extracting

b. tokenizing

c. delimiting

d. parsing

12. The __________ file format is commonly used to export spreadsheet data to a text file.

a. spreadsheet data volume, or SDV

b. comma separated value, or CSV

c. extensible markup language, or XML

d. portable document format, or PDF

13. A __________ is a data type you can create that contains one or more variables

known as fields.

a. structure

b. collection

c. volume

d. list

14. Before you can use a structure to store data, you must create a(n) __________ of the

structure in memory.

a. copy

b. instance
c. declaration

d. reference

15. When the items in two data structures are related by their indexes, it is said that a

__________ exists between the data structures.

a. binary union

b. parallel relationship

c. unilateral bond

d. virtual connection

16. When you create a(n) __________, you specify a set of symbolic values that belong

to that data type.

a. abstract data type

b. symbolic data type

c. enumerated data type

d. cryptic data type

17. __________ are constants that represent integer values.

a. Literals

b. Enumerators

c. Constants

d. Tokens

18. The __________ is a container that can hold multiple images.

a. ImageList control

b. GroupBox control

c. PictureBox control

d. ComboBox control

True or False

1. You cannot store a string in a variable of the char data type TRUE

2. C# allows you to access the individual characters in a string using subscript notation. TRUE

3. When you call a string object’s Split method, the method divides the string into

two substrings and returns them as an array of strings FALSE.


4. The fields contained in a structure must be of the same data type. FALSE

5. Before you can use the structure to store data, you must create an instance of the

structure in memory. TRUE

6. Structure objects can be passed into a method only by reference. FALSE

7. You cannot perform comparison operations directly on structure objects. TRUE

8. Enumerators must be enclosed in quotation Marks FALSE

9. An enum declaration can only appear inside the application’s namespace. FALSE

10. The integer values that you assign to enumerators do not have to be unique. TRUE

11. You can compare enumerators and enum variables with relational operators. TRUE

12. ImageList controls are designed to store small images such as icons or thumbnails. TRUE

Short answer

1. What method can be used to convert a char variable to a string?

The ToString method

5. What characters are used as delimiters when you pass null as an argument to the Split method of
a string object?

Whitespace

6. List the places that a structure can be declared in code.?

1. Outside the application's namespace


2. Inside the application's namespace
3. Inside a class
4. Inside another structure

7. Assume an application contains a structure named Fruit. Write a statement that

demonstrates how you would create a List that can hold Fruit objects.?

List<Fruit> fruitList = new List<Fruit>();

8. Can enumerators be used in a loop to step through the elements of an array? Why or why not?

Yes. Because enumerators represent integer values, they can be used in a loop to step through the
elements of an array.

9. Why should you use the new operator when creating instances of a structure?
You should use the new operator when creating instances of a structure because the new operator
initializes the fields to the default value of 0 or null. An instance with uninitialized fields will result in a
compiler error, so it is a good idea to use the new operator to avoid causing this error.

10. What is the result if the value of the ImageSize property does not match the size of the images that
are stored in the ImageList control?

The images will appear distorted when you display them.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy