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