stud
bud
Sign up
Log in
Home
Library
Explore
SAT
More
Programming II - Midterm Exam Review Flashcards | StudBud
Explore
/
Programming II - Midterm Exam Review
Programming II - Midterm Exam Review
120 terms
·
StudBud Administration
·
57 plays
C# programming midterm exam review.
Flashcards
120 cards
F
Practice quiz
P
Host live
L
Questions
120
Answers
1
How do well-written objects promote re-usable code?
Objects can accurately model real-world things.
All of these are true.
Objects can track useful data and provide useful methods.
Objects can be shared between unrelated applications.
2
Microsoft’s program to ensure that all Windows applications have the same look-and-feel:
Windows Standards
Microsoft Programming Compliance
Microsoft Windows Logo
Windows Common Components
3
Which of the following statements declares a Linked List called “myStrings” of strings?
LinkedList<string> myStrings = new LinkedList<string>();
String myStrings<string> = new LinkedList();
String myStrings = new LinkedList<string>;
System.Collections.LinkedList myStrings;
4
All array variables are of what data type, regardless of what the array contains?
primitive
integers
static
reference
5
Which return value from function “g(x)” is passed directly into function “f()” as a parameter.
f(g(x));
f(g=x);
g(f=x);
g(f(x));
6
Which statement declares and initializes an “int” variable named “myVar” with the value -4765?
myVar int = -4765;
int -4765 = myVar;
int myVar = -4765;
integer myVar = -4765;
7
Which modern programming languages were designed with object-oriented concepts in mind?
COBOL and C
Java and C++
Visual Basic and C#
Java and C#
8
What is the difference between a singly-linked list and a doubly-linked list?
Doubly-linked list can only find the next element.
A doubly-linked list has two or more elements.
Doubly-linked list has two references to the next item.
Doubly-linked list elements can reach previous and next node
9
What method is used to return a string representation of any data type?
ToString()
GetString()
MakeString()
String()
10
What is C#'s end-line character?
;
.
:
,
11
Self-documenting code is
code the original programmer has documented himself/herself.
a feature of some IDEs, but not available in Visual Studio.
a Visual Studio feature which comments for you as you write.
a format for naming variables explaining what they do.
12
What does the keyword “void” mean when it is placed in front of a method declaration?
The method is invalid.
The method will not return a value to the calling code.
The method cannot be used by another class.
The method does not require any parameters.
13
When is it possible for a class to access a property of another class?
Only public properties can be accessed by other classes.
Properties can only be accessed by sub-classes.
All properties can be accessed by any other class.
Only private properties can be accessed by other classes.
14
What three general characteristics can be used to describe objects?
Size, strength, and flexibility.
Data, methods, and relationships.
Methods, data, and efficiency.
Data, algorithms, and scope.
15
What is the meaning of the C# name?
Next generation Java
C-like Object Oriented Language
A note above C
A shorter version of C++
16
Which data type is used to hold only a "true" or "false" value?
int
bool
double
string
17
What language allows you to write a program once and run on many different operating systems?
Java
C++
ANSI C
Visual Basic
18
Replace("p", "t") returns a new string where all the "p" characters are now "t" characters.
False
True
19
What language was created by Microsoft as an answer to Java?
Visual Basic
ANSI C
C++
C#
20
What do “myResult1” and “myResult2” contain after the following code runs?
“This is ” and “This is my ptring”
“my” and “Thip”
“m” and “This is my string”
“my” and “Thip ip my ptring”
21
You wrote an
int
and a
string
to a file, which BinaryReader methods are needed to read them?
Read() and ReadBinary()
ReadInt32() and ReadString()
ReadByte() for both
ReadLine() and ReadToEnd()
22
What is the escape character for inserting a tab?
\tab
\-
\>
\t
23
How would you create a string that contains a double-quote as part of the text?
string myString = "I said, ""Go! "";
string myString = "I said, \"Go!\ "";
You cannot embed double quotes into a string.
string myString = "I said, "Go!"";
24
Which of the following statements add 3 to intNum?
intNum = intNum + 3;
intNum++; intNum++; intNum++;
All of these add 3 to intNum.
intNum += 3;
25
Which characters are used to designate the body of an if() statement or loop?
{ }
[ ]
< >
( )
26
How would you declare a boolean variable named isAccepted and initialize is with a false value?
bool isAccepted = true;
bool isAccepted = false;
bool isAccepted = 0;
bool isAccepted = 1;
27
Value of intNum after the following line of code? int intNum = 1 + 3 * 4 + 6 / 2;
16
20
12
22
28
In Visual Studio, what is an easy way to add code to a button control's click method?
Double-click the button control while in the Design Tab.
Create a boolean called Button_Click and initialize it.
Change the button control's name property to btnClickEvent.
Double-click on the form while in the Design Tab.
29
How do you compare two strings to see if they are the same? Is it case sensitive?
Equals(); yes it is case sensitive
Compare(); yes it is case sensitive
IsEqual(); no it is not case sensitive
Equals(); no it is not case sensitive
30
What language is often used for Rapid Application Development (RAD)?
C++
Java
Visual Basic
C#
31
What method would you call to remove all of the nodes from a linked list?
Clear()
EradicateAllNodes()
DeleteAll()
RemoveAll()
32
How can you determine the number of elements in a one-dimensional array?
Use the ArraySize or ArrayLength properties.
Call the Size() or Length() methods on the array.
Read the Length property or call GetLength(0).
Read the Size property of the array.
33
Value of dblNum after this line of code? dblNum = (1 + (3 * 4 / 6)) / 2;
4.75
1.33
1.0
1.5
34
Which of these is the C# logical operator for "or"?
&&
!
||
^
35
What does a “while” loop do?
Executes as long as some logical expression is true.
Executes a block of code a fixed number of times.
Executes a block of code until the user decides to quit.
Executes until some logical expression becomes true.
36
What is white-space?
Spaces, tabs, carriage returns, used to organize code.
Text that is colored white when displayed to the user.
Symbols like "-" and "_" used instead of spaces.
The pixel padding needed for white pixels.
37
What does the following “mystery” function do?
Returns the greater of the input1 and input2 values.
Prints the values of input1 and input2.
Returns the lesser of the input1 and input2 values.
Computes and returns the sum of input1 and input2.
38
From where can “public” and “private” data be accessed?
Public: by any object. Private: only from abstract methods.
Public: by any object. Private: cannot be accessed.
Public: by any object. Private: only from the same class.
Public: only from within same class. Private: by any object.
39
How would you declare a constructor for the “TicTacToe” class requiring an integer parameter?
public TicTacToe() {int currentPlayer = 0;}
public CurrentPlayer()
public Constructor(int currentPlayer)
public TicTacToe(int currentPlayer)
40
Select the example of two objects that might share an “Is-A” relationship.
Vehicle is-a Bus.
Tea is-a Coffee.
Cat is-a Animal.
Short-Story is-a Novel.
41
What property do you set on the FileOpenDialog to control file extensions the user can select?
Access
Filter
Extensions
Mode
42
What do arrays contain?
A group of values of different types.
A single data value.
A group of methods.
A group of values of the same data type.
43
Write an expression that shows how to access the 4th element in an array called "myData".
myData[4]
myData4
myData[3]
myData(3)
44
What is the endline character that goes at the end of most lines of C# code?
Curly-brace }
Semicolon ;
Solidus /
Bracket ]
45
What is the intermediate form of a compiled .NET application called?
Native machine code
Complete Intermediate Logarithm (CIL)
Common Intermediate Language (CIL)
A class file
46
How would you apply object-oriented concepts to simplify a complex system?
Separate all methods and properties from each other.
OOP concepts cannot be used to simplify a complex system.
Break it down into smaller parts so they can be understood.
Create larger and larger objects until the object is huge.
47
What is a linked list?
A group of linked array structures.
Data structure of elements accessed using an index value.
Data structure that holds a series of elements called nodes.
A special kind of array.
48
BinaryWriter myWriter = new BinaryWriter(File.Open("c:\\new.dat", FileMode.Create));
“C:\new.dat” is created and opened, replacing any old file.
“C:\new.dat” is created ONLY if it does not currently exist.
“C:\new.dat” is opened for text reading.
An existing file “C:\new.dat” is opened for writing.
49
What is a constant variable?
Variable with special naming rules that must be followed.
All of these are true.
Variable whose value can never be changed within a program.
Variable that can only hold whole integer data.
50
How do you access the first and last character of myString of length 5?
myString[1] and myString[4]
myString[1] and myString[5]
myString[0] and myString[4]
myString[0] and myString[5]
51
Which statement ensures the currentPlayer member can only be accessed by TicTacToe objects.
Public int currentPlayer;
Static int currentPlayer;
Protected int currentPlayer;
Private int currentPlayer;
52
Which one of the following is an advantage of the C# language over the C language?
All of these are advantages
C# supports the .NET Framework
C# contains automatic memory management
C# is an object-oriented language from the ground up
53
How would you declare a character variable named myChar and initialize it with the letter 'A'?
Dim myChar As Char = "A"
myChar char = 'A';
char myChar = 'A';
character myChar = 'A';
54
What is an advantage of using a linked list over an array?
Both of these are true.
Neither of these are true.
Linked lists can change size without reallocating elements.
You can add or remove elements from the middle of the list.
55
What invention made the use of graphical programs faster and easier?
The computer mouse
Sound cards
Keyboards
DVD discs
56
Which of the following best describes the .NET Framework?
Library of pre-built functions accessed by many languages
All of these are true
A safety net designed to catch program crashes
Library of pre-built functions for Linux and Mac OSX
57
What IBM operating system was an early competitor to Windows?
OS/2
Lisa
Unix
DOS
58
Which of these is the C# logical operator for "and"?
||
^
&&
!
59
How would you best visualize a one-dimensional and two-dimensional array?
A 1-D array is a grid and a 2-D array is a line of elements.
A 1-D array is a short line, a 2-D array is a long line.
A 1-D array is line and a 2-D array is grid of elements.
A 1-D array is grid and a 2-D array is cube of elements.
60
In what form do computers store all data?
Alphanumeric
Text
Decimal (0 through 9)
Binary (1's and 0's)
61
What method can be used to convert a string to a numeric data type?
Parse()
Convert()
ToNumber()
You can directly cast from string to a number.
62
What are namespaces?
Groups of commonly used objects and methods.
The names of your projects within the Solution Explorer.
Directories in which you organize your projects.
A pattern for naming your source files on disk.
63
Select TWO programming languages that commonly use the .NET Framework.
Visual Basic
Java
C#
C++
64
What version of Windows was the first fully 32-bit operating system?
Windows 8
Windows NT
Windows 3.0
Windows 7
65
What is a “for” loop?
Loop that uses a string index variable.
Loop that will never exit.
Loop that executes a block of code a fixed number of times.
Loop that exits when the user selects the right value.
66
Which of the following statements will create a new TicTacToe object?
new TicTacToe;
new class TicTacToe;
TicTacToe();
new TicTacToe();
67
What type of loop never stops executing?
recursive loop
for() loop
while() loop
infinite loop
68
What was the original name Microsoft came up with for the C# programming language?
D
COOL
C++
C-BETTER
69
Which data type would be the BEST choice for storing the number -18.2359014?
char
int
byte
double
70
Which statement below will create the following directory hierarchy: “c:\my\new\directory”?
Directory.CreateDirectory("c:\\my\\new\\directory");
File.CreateNew(DIR, "c:\\my\\new\\directory");
File.CreateDir("c:\my\new\directory");
Directory.CreateNew("c:\my\new\directory");
71
What function is used to change all of the letters in a string to upper-case characters?
Transform(String.Upper)
ToString(String.Upper)
MakeUpperCase()
ToUpper()
72
What is the biggest advantage of compiling a program to an intermediate language?
The same program can be distributed to multiple platforms
It shows errors in your code more clearly
It takes less time than compiling to machine code
It hides your internal code secrets from others
73
How do you change a variable value by sending it to a method as a parameter?
You can never change a variable in the calling code.
Use the “out” keyword.
Use the “global” keyword.
Use the “change” keyword.
74
Name one other interchangeable term used to refer to a “method”?
function
block
technique
loop
75
It’s important to do what task when you are finished reading or writing a file?
Call Close() to release the file resources.
Call Encrypt() to encrypt the data in the file.
Call GetLast() to make sure you have read/written all data.
Call End() to finalize the reading or writing process.
76
When was the first version of Windows released?
1990
1976
1985
2001
77
What was the name of the original, text-based operating system for home computers?
DOS
Windows
Mac OS
Lisa
78
Which of the following classes is your favorite?
class Programming_II
class Programming_II
79
Which statement declares a private static string “PLAYER1_SYMBOL” and initialize it to “X”?
private string PLAYER1_SYMBOL : X;
private static string PLAYER1_SYMBOL = "X";
static string PLAYER1_SYMBOL = "X";
protected char PLAYER1_SYMBOL = 'X';
80
What need resulted in the creation of the “Simula 67” programming language?
The need for a simpler, more robust programming language.
The need to model complex ships that shared common traits.
The need to handle large amounts of data.
The need to create complex mathematical simulations.
81
Name one mathematical constant that is pre-defined in the .NET Framework.
DIAMETER
PI
INFINITY
GRAVITY
82
Which of the following statements are true about relationships between objects?
Has-a relationship are owned by one another.
All of these are true.
Uses-a relationship use the other’s public methods and data.
Is-a relationship inherit common traits and behavior.
83
Which of these expressions returns true if the file "c:\readme.txt" exists, or false otherwise?
File.IsFile("c:\readme.txt")
Directory.Exists("c:\\readme.txt")
File.Exists("c:\\readme.txt")
if ( File("readme.txt") )
84
What is one of the main differences between text boxes and labels?
Labels can be edited by the user, and text boxes cannot.
Text boxes are only single-line, labels are multi-line.
Text boxes can be edited by the user, and labels cannot.
They are basically the same control.
85
What keyword can be used to exit a loop immediately regardless of the test condition?
halt
exit
break
stop
86
How do parentheses help to clarify a math statement?
Both of these are true.
Neither of these are true.
Parentheses make it more obvious to humans what will happen.
Parentheses execute first regardless of precedence rules.
87
What are the only two possible results of evaluating a logical expression?
true or false
0 or 1
pro or con
yes or no
88
In Visual Studio, where would you go to add a new control to your Windows form?
Properties Window
Error Window
Solution Explorer
Toolbox Window
89
Value of intNum after this line of code? intNum = (1 + 3) * 4 + (6 / 2);
20
12
19
16
90
A class property must have the following data type:
A string data type.
A reference data type.
Any data type.
Another class type.
91
More than one control can share the same name as long as they are different types of controls.
True
False
92
What object and method would you use to write a line of text to a text file?
StreamWriter.Write()
StreamWriter.WriteLine()
File.Write()
File.WriteLine()
93
ToUpper() returns a new string where the contents have been converted to lower case.
True
False
94
When calling a method, why is the order of parameters provided to the function important?
The parameters must be arranged in order of size.
The parameters must all be in alphabetical order.
The order of the parameters is not important at all.
Data is assigned to parameter variables in order passed.
95
What is the difference between a “signed” data type and an “unsigned” data type?
Signed integers can also hold real (fractional) values.
Signed data types can hold a larger positive number.
Signed data types can hold numbers less than zero.
Unsigned data types have no variable name (anonymous).
96
Which two math functions get the next biggest or smallest whole number from a real number?
Ceiling()
Floor()
Min()
Max()
97
What is wrong with the following code?
The class definition should come before the function.
You cannot declare a function outside of a class.
Nothing, this will compile just fine.
The function name is not valid.
98
What type of “while” loop will always be executed at least once?
while() loop
Both of these will always execute at least once.
Neither of these will execute at least once.
do while() loop
99
How do similar objects share common data and methods?
Objects are not allowed to share common data or methods.
Using enumeration.
Using return values.
Inheritance or sub-classing.
100
What is an “if” statement used for in a program?
To execute a block of code if a condition is false.
To ask the user a question.
To execute a block of code in a loop.
To execute a block of code if a condition is true.
101
Why would you want to design an object as a “black box”?
So everyone knows exactly how the object is implemented.
To be stylish and sleek.
To hide the internal details so we can change them later.
To make it large enough to hold all the data.
102
Where should your method definition go within a source file?
All these are possible locations.
Inside the namespace curly braces.
Just inside the curly braces of another function
Just inside the class curly braces.
103
What is wrong with the variable name “321_liftoff”?
Variable names cannot contain underscores (_).
Variable names cannot begin with numbers.
Variable names must begin with a letter.
There is nothing wrong with that variable name.
104
What is the purpose of a file extension?
To add more data to a file.
To compress the file to save space.
To prevent access to the file.
To identify the type of data stored within a file.
105
What is an IDE?
A tool to help you figure out what kind of program to write
Integrated Debug Effort (IDE)
Important Development Engine (IDE)
A central place to write, build, run, and debug code
106
Are the methods “MyMethod()” and “myMethod()” viewed as the same method by the compiler?
Maybe, it depends on the contents of the methods.
Yes, neither method requires parameters, they are the same.
Yes, the methods are named the same.
No; method names are case sensitive.
107
Why is it important to give forms and controls meaningful names?
The IDE wont create unique names; it’s up to you.
So you can identify the purpose of a control in your code.
Projects wont build unless you name each form and control.
You can’t create an event handler without a meaningful name.
108
When is a class constructor method called?
When the object is created with the “new” keyword.
The first time any class method is used in a program.
Whenever you assign a value to a class property.
None of these are true.
109
What is one reason to create or use a method?
All of these are good reasons.
Eliminate repetitious code.
Execute the same task from different parts of your program.
Make code easy to follow and understand.
110
What characters are allowed to start a C# method name?
Letters only.
Letters or underscores (_).
Underscores (_) or numbers.
Numbers and letters.
111
Which computer had the first graphical operating system?
Windows
Unix
Lisa
Android
112
What do operator precedence rules determine?
The mathematical operations carried out by one operator.
The order entire statements will execute (flow control).
Order of execution of multiple mathematical operators.
The effect that parentheses have on an expression.
113
What three math operators are executed first? What two operators are executed last?
First are +, -, and %. Last are * and /
First are *, /, and %. Last are + and -
All operators execute from left to right.
First are +, /, and -. Last are * and %
114
Which IDE will we be using this year to write C# programs?
MonoDevelop
Visual Studio
SharpDevelop
Xamarin Studio
115
What are comments used for in a program?
Fixes compile-time errors as they occur during run-time.
None of these.
Explains things to the user.
Helps the programmer understand the code.
116
Which of these is not a comparison operator?
=
<
<=
>
117
Which of the following best describes a variable?
Names given to blocks of code within your program.
Named places to store data in your program.
A description of an object.
An unpredictable piece of code.
118
What return value from Open/SaveFileDialog means the user has clicked on Open or Save buttons?
DialogResult.Open
OK_BUTTON
DialogResult.Save
DialogResult.OK
119
What object and function would you use to get the next line of text from a text file?
StreamReader.Read()
File.ReadLine()
StreamReader.ReadLine()
File.Read()
120
Why is it a good idea to declare internal methods and data as “private”?
Both of these are true.
Hide internal implementation so it can be freely changed.
Prevent objects from accidentally changing internal data.
Neither of these are true.