CNIT 175 Quiz questions

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

In the following code assume that the data values in the string variable Line are separated by a tab character. Dim Line as String Line = "A 33 5.5" Dim Parts() As String Parts = Line.Split(vbTab) What will be stored in Parts(1) ?

"33"

Assume the file contains 4 lines as follows. Abe 32 Kim 18 Sara 22 Fara 26 What will be stored in string variable S in the following code? Assume the file has been opened for reading and SR is referring to the file. Dim S As String S = SR.ReadLine() S = SR.ReadLine()

"Kim 18" Response Feedback: Each readline reads one line from the file into variable S. The second readline will read "Kim 18" into S.

Peek method returns--------------- when end of the file is reached.

-1

Validation for Combo Box Validation: if : cboColor.SelectedIndex = [ ] Then Messagebox.Show("Select a variable in the Combo Box.")

-1

What is the result of the arithmetic expression shown below? -10 ^ 2 + 4

-96

Steps for reading the text files

-Read one line at a time (SR.Readline() ) -Split it based on the delimiter (vbTab) -store the data in the array of structure

The index value for the 1st element in an array is __________.

0

What is the lowest index in array Value? Dim Value(100) As Double

0

What are the values stored in the array after execution of the following statements? Private mData() As Integer ReDim mData(1) mData(0) = 5 mData(1) = 7 ReDim mData (3) mData(3) = 11

0, 0, 0, 11

What will be displayed? Dim Ctr As Short For Ctr = 1 To 10 Step 2 lblOutput.Text = lblOutput.Text & Ctr.ToString() & vbLf Next Ctr

1, 3, 5, 7, 9

What will be displayed? Dim N As Integer Do while N <= 10 N = N + 2 Loop lblOutput.Text = N.ToString()

12

What is displayed in the label after executing the following segment of code? Dim Ctr As Integer For Ctr = 1 To 10 Step 3 ... Next Ctr lblOutput.Text = Ctr.ToString()

13

Evaluate the arithmetic expression shown below. 2 + 3 * 4

14

What will be stored in N3 by the following? Dim N1 As Short = 11 Dim N2 As Short = 15 Dim N3 As Short = 3 If N1 < N2 Then N3 = N1 + N2 End If If N2 < N3 Then N3 = N2 End If

15

The index value for the 3rd element in an array is __________.

2

What is the result of the operation shown below? 5 Mod 3

2

What is the result of the operation shown below? 3 ^ 3

27

What is the output? Dim N As Short = 4 Dim Sum As Short = 0 Do While N <= 10 Sum = Sum + N N = N + 2 Loop lblOutput.Text = Sum.ToString()

28

X = 5, y = 8, z = 2 Only one of the branches will get executed. If x < y + z Then z = y - x ElseIf x < y Then z = x Else z = x + y End If Z = ?

3

What will be displayed by the following code? Dim N As Short Dim Answer As Short = 1 For N = 1 To 5 Step 1 Answer = Answer * 2 Next N

32

What will be stored in M? Dim M, N As Short M = 5 N = 7 If M < N Then If N < 10 Then M = 10 - N Else M = N - 10 End If M = M + 1 Else M = N - M End If

4

How many times will the following loop execute? Dim Ctr As Integer For Ctr = 1 To 10 Step 3 ... Next Ctr

4 times

What will be displayed if the user starts the program and clicks on the button 5 times? Private N As Integer Private Sub btnOK_Click (......................) N = N + 1 lblShow.Text = N.ToString() End Sub

5

What will be stored in the array after execution of the following code? Private mData() As Integer ReDim mData(1) mData(0) = 5 mData(1) = 7 ReDim Preserve mData (3) mData(3) = 11

5, 7, 0, 11

How many values can be stored in array Numbers? Dim Numbers(60) As Integer

61

Evaluate the arithmetic expression shown below: 2 * (12 + 5) Mod 9

7

When creating a text file for saving data generated in the program use the [A] method of the File class.

A - CreateText

A loop that continues forever is referred to as an [A] loop.

A - Infinite

Global variables should be be declared in a [A]?

A - Standard Code Module

The ______________ method is used to add another item to a ListBox at runtime.

Add

Fill in the blank. The goal is to make sure that N is in range of 0 to 10. If N >= 0 ------ N <= 10 Then lblShow.Text = "Valid Range" Else lblShow.Text = "Out of range" End If

And

In a pre-test loop, when is the loop condition evaluated? (Beginning, middle, end, or never?)

At the beginning of each cycle

Try - Catch - Finally will handle ________ errors.

runtime errors

Try ... _______________ ... Finally ... End Try

Catch Ex As Exception

Connecting two strings to form a longer string is called ________________.

Concatenation

Which of the following takes place when saving data to the file? A. Data is transferred from the file to dynamic array of structure. B. Data is transferred from the RAM to the hard drive C. Data is transferred from the Textbox into variable. D. Data is transferred from the hard drive to the RAM

Data is transferred from the RAM to the hard drive

What data type should to declare a variable for monetary values?

Decimal

The keyword for declaring a local variable is -----------.

Dim

Given: Private Structure mTriangle Dim Side1 As Single Dim Side2 As Single Dim Side3 As Single End Structure Declare an array to store 10 triangle records.

Dim Shapes(9) As mTriangle

What kind of loop is best for reading from the Text Files?

Do Until (Do Until SR Peek() = -1)

It is recommended to open the second form as modeless form. (True/False)

False

What is the outcome of the following expression? "100" < "80" (True / False)

False

A ______________ array is one that can NOT be resized during program execution.

static

Fill in the blank to open/read the text file Dim SR As StreamReader Dim Line As String Dim Parts() A String SR = ________________("Files.txt")

File.OpenText

Assume the goal is to display the array's content on the second form as it loads on the screen. Where should the code for displaying the array be written?

FormLoad event of the second form.

Dim N As Integer N = 78 If N > 10 Then lblOutput.Text = "Good" ElseIf N < 100 Then lblOutput.Text = "Fair" ElseIf N > 50 Then lblOutput.Text = "OK" Else lblOutput.Text = "Poor" End If

Good

What will be displayed by the following? Dim N As Short N = 12 If N >= 10 Then lblShow.Text = "Great" ElseIf N >= 8 Then lblShow.Text = "Good" Else lblShow.Text = "Bad" End If

Great

When opening a file with AppendText() for writing / appending, if the file does not exist -----------------.

It gets created.

The _______________ operator is used to find the remainder of a division.

Modulus (Mod)

Fill in the blank. The goal is to issue a warning if the tempertature is outside the range of 0 to 100 both inclusive. Dim Temp As Short = ... If Temp < 0 ------- Temp > 100 Then lblShow.Text = "Warning!" End If

Or

Assume a variable 'PetName' of type String has already been declared. What statement would assign the name "Luna" to the variable PetName?

PetName = "Luna"

Assume a variable 'Price' of type Decimal has already been declared. What statement would assign 3.99 to the variable Price?

Price = 3.99

Module Scope keyword

Private

Which of the following will declare a module scope dynamic array to store some whole numbers? A. ReDim Preserve mNumbers() As Integer B. ReDim mNumbers() As Integer C. Private mNumbers() As Integer D. Private mNumbers(100) As Integer

Private mNumbers() As Integer

What is the keyword for declaring project scope variables?

Public

Resize the given array to have 10 elements- do NOT preserve the existing values. Dim Data() As Integer

ReDim Data(9)

Resizing a dynamic array: (mArray)

ReDim Preserve mArray(---)

How do you close the reading file?

SR.Close()

what method of the Form class must be used to open a form as a modal form?

ShowDialog()

Peek is a method of [A] class.

StreamReader

A ____________________ literal is a stream of characters enclosed between double quotes " ".

String

Exists() is a method of which class?

Systems.IO.File

The _______________ property of an object is the text displayed on it.

Text

What type of files can be viewed and understood by humans?

Text Files

What is the outcome? Dim N As Short Dim Sum As Short Do While N <= 10 Sum = Sum + N Loop lblOutput.Text = Sum.ToString()

This is an infinite loop, program will be locked in the loop.

What will be displayed? Dim N As Short = 1 Dim Sum As Short = 0 Do While N >= 10 Sum = Sum + N N = N + 2 Loop lblOutput.Text = Sum.ToString()

This loop will not execute at all. 0 will be displayed

Assume the names and scores of students are stored in two parallel arrays: mName and mScore. Assume that the name "King" is stored at mName(8) - Where would be the score of this student?

This student's score would be at mScore(8)

The _____________ method converts a numeric data to its String equivalent.

ToString

A dynamic array can be resized to a smaller size or to a bigger size as needed. (True / False)

True

End of the file should be checked when reading from a file. (True/False)

True

In VB it is possible to write a general function or a general procedure with project (global) scope. (True/False)

True

Member of a Structure can be another Structure. (True/False)

True

What will be stored in array Data by the following statements? Dim Data() As Short ReDim Data (1) Data(0) = 10 Data(1) = 11 ReDim Data(2) Data(2) = 12

Values 0, 0, 12 will be stored in Data(0), Data(1) and Data(2)

Refer to the 'New Project' dialog box pictured below when answering the question: The type of program being created is a __________________ Application. (The form used for every single lab/assignment)

Windows Forms

The _______________ method is used to clear all items displayed in a ListBox at runtime.

clear

To change the value stored in a variable, it should appear on the ___________ side of the assignment operator.

left

Programming languages use __________ to store and remember data values in a program

variables

When the Else part of an If statement is another If statement, we can use the [x] keyword. This simplifies the indentation of the code and requires fewer End If.

x - ElseIf

The scope of a module scope variable is the entire [x], and its lifetime the duration of the [y].

x - Form y - Program

Generally speaking, a variable is a location in [x] with a designated [y] where you can store a [z] that can be used or changed during the execution of the program.

x - RAM y - name z - value

[x] coding structure involves executing different statement(s) based on the outcome of some condition.

x - Selection

When you code one If statement INSIDE another If statment, it is referred to as [x] If statements.

x - nested

[x] coding structure involves executing one statement after another in sequence.

x - sequential


Ensembles d'études connexes

Chapter 2 Section 3 - Falling Objects

View Set

The Science of Nutrition Chapter 4 Questions

View Set

Unit 3 Lesson 2 Unemployment (Waldonomics)

View Set

Prep U Questions Chapter 7: Legal Dimensions of Nursing Process

View Set

Caring for the Older Adult PREPU

View Set

Marketing Exam 2 Multiple Choice

View Set