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