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