6 Select number lstBox.Items.Add(query.Count) lstBox.Items.Add(query.Average) (A) 5 and 12 (B) 2 and 12 (C) 2 and 8 (D) 5 and 8 19. What years are displayed in the list box by the following program segment? Dim years() As Integer = {1492, 1776, 1840, 1929, 1945, 2005} Dim query = From year in years Where Is20thCentury(year) Select year For Each year in query lstBox.Items.Add(year) Next Function Is20thCentury(num As Integer) As Boolean If (num >= 1900) and (num < 2000) Then Return True Else Return False End IF End Function (A) 1929 and 1945 (B) 1929 (C) 1492, 1776, 1840, 1929, 1945, 2005 (D) No years 21. Suppose a structure and an array are created with the code Structure Nation Dim name As String Dim continent As String Dim population As Double 'in millions Dim area As Double 'in square miles End Structure Dim nations(191) As Nation in the Declarations section of the Code editor and the array is filled with data for the 192 member nations of the UN. What will be displayed in the list box when the following code is executed? Dim query = From country In nations Where country.continent = "Africa" Order By country.population Descending Select country.name lstBox.DataSource = query.ToList lstBox.SelectedIndex = Nothing (A) the names of the countries in Africa in alphabetical order (B) the names of the countries in Africa beginning with the name of the least populous country (C) the names of the countries in Africa beginning with the name of the most populous country (D) the names of the countries in Africa in reverse alphabetical order - Visual Basics Questions? - CodingCore.com - Webmaster Forum, Coding Forum, Programming Forum, Codes, Coders, Programmers, Webmaster Forum, Coding Forum, Programming Forum , Coding Core." /> be displayed in list box when button is clicked? Private Handles btnDisplay.Click Dim Double = 10 - Coding Core, Webmaster Forum, Coding Forum
View Single Post More
Old 12-14-2011, 02:08 AM   #1 (permalink)
Marili
 
Status: Junior Member
Posts: 2



Default Visual Basics Questions?

1. What numbers will be displayed in the list box when the button is clicked?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim num as Double = 10
Do While num > 1
lstBox.Items.Add(num)
num = num - 3
Loop
End Sub
(A) 10, 7, and 4
(B) 10, 7, 4, and 1
(C) 10, 7, 4, 1, and -2
(D) No output

5. What numbers will be displayed in the list box by the following code when the button is clicked?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim num As Integer = 7
Do
num += 1
lstBox.Items.Add(num)
Loop Until (num > 6)
lstBox.Items.Add(num)
End Sub
(A) 7
(B) 8
(C) 7 and 8
(D) 8 and 8

11. Which of the statements will unhighlight any highlighted item in lstBox?
(A) lstBox.SelectedItem = Nothing
(B) lstBox.SelectedItem = ""
(C) lstBox.SelectedIndex = 0
(D) lstBox.SelectedIndex = -1

14. In the line of code
Dim scores() As Integer = {55, 33, 12}
the upper bound of the array scores is 12. (T/F)

15. What two names are displayed in the list box when the button is clicked on?
Dim krispies() as String
Private Sub frmCereal_Load(...) Handles MyBase.Load
krispies(0) = "snap"
krispies(1) = "crackle"
krispies(2) = "pop"
End Sub
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
lstBox.Items.Add(krispies.Max)
lstBox.Items.Add(krispies.Last)
End Sub
(A) crackle and pop
(B) crackle and snap
(C) snap and crackle
(D) snap and pop

16. What is the output of the following program when the button is clicked on?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim result As Double
Dim number(4) As Double
FillArray(number)
result = SumArray(number)
txtBox.Text = CStr(result)
End Sub

Sub FillArray(ByRef anyArray() As Double)
Dim temp() As String = IO.File.ReadAllLines("Data.txt")
For i As Integer = 0 To 4
anyArray(i) = CDbl(temp(i))
Next
End Sub

Function SumArray(ByVal anyArray() As Double) As Double
Dim total As Double
total = 0
For i As Integer = 0 To 4 Step 2
total += anyArray(i)
Next
Return total
End Function

Assume the five rows of the file Data.txt contain the following entries: 1, 3, 5, 7, 9
(A) 0
(B) 25
(C) 15
(D) None of the above


17. What names are displayed in the list box by the following lines of code?
Dim oceans() As String = {"Atlantic", "Pacific", "Indian", "Arctic", "Antartic"}
Dim query = From ocean in oceans
Where ocean.Length = 6
Select ocean
For Each ocean As String In query
lstBox.Items.Add(ocean)
Next
(A) Pacific and Indian
(B) Indian and Arctic
(C) Indian
(D) Atlantic and Pacific

18. What numbers are displayed in the list box by the following program segment?
Dim numbers() As Integer = {4, 7, 9, 3, 1}
Dim query = From number in numbers
Where number > 6
Select number
lstBox.Items.Add(query.Count)
lstBox.Items.Add(query.Average)
(A) 5 and 12
(B) 2 and 12
(C) 2 and 8
(D) 5 and 8

19. What years are displayed in the list box by the following program segment?
Dim years() As Integer = {1492, 1776, 1840, 1929, 1945, 2005}
Dim query = From year in years
Where Is20thCentury(year)
Select year
For Each year in query
lstBox.Items.Add(year)
Next
Function Is20thCentury(num As Integer) As Boolean
If (num >= 1900) and (num < 2000) Then
Return True
Else
Return False
End IF
End Function
(A) 1929 and 1945
(B) 1929
(C) 1492, 1776, 1840, 1929, 1945, 2005
(D) No years


21. Suppose a structure and an array are created with the code
Structure Nation
Dim name As String
Dim continent As String
Dim population As Double 'in millions
Dim area As Double 'in square miles
End Structure
Dim nations(191) As Nation
in the Declarations section of the Code editor and the array is filled with data for the 192 member nations of the UN. What will be displayed in the list box when the following code is executed?
Dim query = From country In nations
Where country.continent = "Africa"
Order By country.population Descending
Select country.name
lstBox.DataSource = query.ToList
lstBox.SelectedIndex = Nothing
(A) the names of the countries in Africa in alphabetical order
(B) the names of the countries in Africa beginning with the name of the least populous country
(C) the names of the countries in Africa beginning with the name of the most populous country
(D) the names of the countries in Africa in reverse alphabetical order

Marili is offline   Reply With Quote
more..