Font size
WorksheetsQuiz on Visual Programming
Total questions: 145
Worksheet time: 2hrs 30mins
To change the Color Theme of Visual Studio .Net, which menu do we select?
Tools/ Options/ General.
View/ Toolbox.
Extensions/ Customize Menu.
Tools/ Customize.
VB.NET allows users to set up applications according to?
Console, Windows Form, ASP.NET.
Windows Form.
ASP.NET.
Console.
The term IDE stands for?
Integrated Development Environment.
Integrated Design Environment.
Interior Development Environment.
Interior Design Environment.
The term CLR stands for?
Common Language Runtime.
Common Language Run.
Class Language Runtime.
Class Language Run.
For the following code, what is the function of the Console.ReadKey() command? Sub Main() Console.WriteLine(Console.ReadLine()) Console.ReadKey() End Sub
To pause the screen to view the result.
To read data from the keyboard.
This command is used to print values to the console.
This command reads 1 character from the keyboard and returns an integer.
To create a TextBox control on a Form, we use?
Toolbox.
Toolbar.
Project Explorer window.
Properties Window.
In a Solution with 3 projects, to set a project as the default running project in the Solution, we select?
Right-click on the project to run by default/ Set as Startup Project.
In a Solution, there can only be one Project.
The first created project is the default running project, it cannot be changed.
Select My Project in the project to run by default, change the Startup form.
The command that reads data from the keyboard until it encounters a newline character is?
Console.ReadLine()
Console.WriteLine()
Console.WriteLine.
Console.Read()
The command that prints each value on a new line is?
Console.WriteLine()
Console.WriteLine.
Console.Read()
Console.ReadLine()
For the following procedure: Sub Main() Console.WriteLine("Please enter Name, Age, Address:") Console.Write("Your name: " + Console.ReadLine() + ", " + Console.ReadLine() + " years old, living in " + Console.ReadLine() + ".") End Sub If the user enters: Marry, 20, California. What is the result?
Your name: Marry, 20 years old, living in California.
The program reports an error.
Your name: Marry 20 years old living in California.
Your name: Marry + 20 years old + living in California.
What is the result of the following program? Dim a, b As String a = "1" b = "2" MsgBox(a + b)
12.
3.
Error on line 1.
Error on line 4.
Assuming the value x=10. Which of the following commands will print the result in the textbox named txtKetQua?
How many is the result of the expression?
Assuming x=10. Which statement will print the result in the textbox named txtKetQua?
txtKetQua.Text=str(x)
Print(x.KetQua)
txtKetQua.Print(x)
txtKetQua.x=10
Variable names, constants, and subroutine names cannot use which of the following characters?
Space.
Uppercase letters.
Digits.
Lowercase letters.
To use x raised to the power of y, which function or operator should be used?
x ^ y
exp(x,y)
pow(x,y)
Another function.
To perform integer division of a by b and get the remainder, which syntax is correct?
a mod b
a % b
a / b
a \ b
To perform integer division of a by b and get the integer part, which syntax is correct?
a \ b
int (a / b)
a / b
a div b
To declare a constant in VB.Net, which syntax is correct?
Const
Const
Private
Dim
In VB.Net, to access the third element of array A, which syntax is correct?
A(2)
A[3]
A[2]
All are incorrect.
The function to convert a string variable Str from date string type to date data type is?
CDATE(Str)
Date(Str)
Convert.ToDate(Str)
ConverDATE(Str)
To convert a string variable containing numeric characters to an integer type, which function should be used?
cint(
change integer(
chr(
asc(
In the For statement, if the Next keyword is omitted, what happens?
The For statement is incorrect.
It does not affect the statement, each iteration increases by 1.
The statement is always considered correct (infinite loop).
The loop is infinite.
Which structure has a defined number of iterations?
For … Next
Do while…Loop
Do until….Loop
Do…Loop until
In the Do
At least 1 time.
At most 1 time.
At least 0 times.
All are correct.
Declare an array as follows: Dim A As Integer() = New Integer(4). How many elements does array A have?
5
3
1
Another value.
What is the result of the following program when run with n = 20?
good3
good1
good2
The program reports an error
What is the result of the following program after running the code?
All answers are incorrect.
One
Two
Three
How many times does the following For loop execute?
What does the following program do? X = " " 'empty string For Each varX In Array("one", "two", "three") X = X + varX Next Print X
All answers are wrong.
One
Two
Three
How many times does the following For loop execute? Sub Main() Dim Array As String() = New String(2) {"one", "two", "three"} Dim X As String X = " " For Each varX In Array X = X + varX Next Console.WriteLine(X) Console.ReadLine() End Sub
3 times.
1 time.
2 times.
4 times.
What will the following program output? Dim x, y, m As Integer x = 1 : m = 0 While x <= 5 y = x ^ 2 : Console.WriteLine(y) m = m + y : x = x + 1 End While
1 4 9 16 25
2 4 6 8 10
1 4 6 9 25
3 4 5 6 72
What will the following program output? Dim x, y, m As Integer x = 1 : m = 0 While x <= 5 x = x + 1 : y = x ^ 2 Console.Write(y.ToString & " ") m = m + y End While
4 6 9 16 25 36
1 4 9 16 25
2 4 6 8 10
3 4 5 6 72
What does the following program do? Dim x As Integer, y As Integer For x = 1 To 9 For y = 1 To 9 If x + y = 10 Then Console.WriteLine(x * 10 + y) Exit For End If Next y Next x
Prints two-digit numbers whose digits sum to 10.
Prints all numbers from 1 to 99.
Prints numbers from 10 to 99.
All options a, b, c are wrong.
What will the following command output? Sub Main() For i As Integer = 1 To 5 If i = 3 Then Continue For Console.Write(" {0} ", i) Next Console.ReadLine() End Sub
1 2 4 5
1 2 3 4 5
1 4 5
0 1 2 3 4 5
What will the following command output? Sub Main() Dim i As Integer = 0 While i < 4 i += 1 If i = 2 Then Continue While Console.Write("{0} ", i) End While Console.ReadLine() End Sub
1 3 4
1 2 4
1 2 3 4
No correct answer.
What will the following command output? Sub Main() Dim i As Integer = 1 Do Console.Write("{0} ", i) i += 1 If i = 2 Then Continue Do Loop While i < 4 Console.ReadLine() End Sub
1 2 3
1 2 4
1 4
1 2 3 4
What will the following command output? Sub Main() Dim x As Integer = 20 Select Case x Case 10 Console.WriteLine("x = 10") Case 15 Console.WriteLine("x = 15") Case 20 Console.WriteLine("x = 20") Case Else Console.WriteLine("Undefined") End Select Console.ReadLine() End Sub
x = 20
x = 15
x = 10
Undefined.
What will the following command output? Sub Main() Dim i As Integer Dim S As Integer = 0 For i = 1 To 20 Step 1 S = S + i Next Console.Write(" Total = " & S) Console.ReadLine() End Sub
210
200
100
No correct answer.
What does the following code do? Sub Main() Dim i As Integer Dim S As Integer = 0 For i = 1 To 20 Step 1 S = S + i Next Console.Write(" Tong la = " & S) Console.ReadLine() End Sub
210
200
100
No correct answer.
What does the following code do? Sub Main() Dim names As String() = New String(2) {" Nhom 2", " Nha Co ", " 4 chi em"} For Each name As String In names Console.WriteLine(name) Next Console.ReadLine() End Sub
Prints the values in the string on 3 lines.
Prints the values in the string on 1 line.
Reports an error.
Prints nothing.
What does the following code do? Sub Main() Dim array As Integer() = New Integer(4) {8, 2, 3, 4, 9} For i As Integer = 0 To array.Length - 1 Console.WriteLine(array(i)) Next Console.ReadLine() End Sub
Prints the elements of the array.
Calculates the sum of the elements of the array.
Inputs the elements of the array.
Sorts the array in ascending order.
What is the value of the variable counter after executing the following code? Sub Main() Dim counter As Integer counter = 1 Do Until counter > 5 counter = counter + 1 Loop MsgBox("Gia tri hien tai cua counter la: " & counter) End Sub
6
5
1
4
For the following program, which statement is correct? Private Sub Doiso() Dim bytX As Byte, intY As Integer intY = 1234 bytX = intY End Sub
The program will report an error when running (Run-time error).
The program will report an error due to invalid variable declaration.
The program will run successfully.
All three answers above are incorrect.
What will the following program output? Public Function AAA(ByVal x As Long) For i = 2 To x - 1 x = x * i Next AAA = x End Function Sub Main() Console.WriteLine("Ket qua : " & AAA(5)) Console.ReadLine() End Sub
120
5
240
The program reports an error.
What is encapsulation?
A mechanism that binds data and operations on that data into a single unit, preventing unexpected external effects. This unit is called an object.
A mechanism that divides a program into functions and procedures that perform separate tasks.
A mechanism that prevents other components from accessing its internals.
A mechanism that shows a function can have multiple instances at different times.
What is inheritance?
The ability to build new classes from old classes, where the new class is called a derived class and the old class is called a base class.
The ability to reuse previously built functions.
The ability to reuse previously built data types.
All are correct.
What is polymorphism?
What is polymorphism?
The ability of a message to change its representation based on the specific class of the object receiving the message.
The ability of a message to be passed to its subclass.
The ability of a function or procedure to be inherited.
The ability of a function or procedure to be reused.
What is an object class?
A design or template for objects of the same type.
A specific instance for objects.
A set of elements of the same type.
A set of values of the same type.
In the following options, which option describes polymorphism?
Classes Point, Circle, Square, Rectangle... all have a Draw method.
Class Circle inherits from class Point.
Class Square inherits from class Rectangle.
Classes Point and Circle both have constructors and destructors.
When declaring and building a class, what components must be clearly defined?
Attributes (data) and methods (behavior) of the class.
Data and objects of the class.
Concepts and objects of the class.
Countless components.
For the following program segment: Class A Private x As Integer Public y As Integer End Class Sub Main() Dim obj1, obj2 As New A() obj1.x = 10 obj2.y = 8 End Sub At which line does the program have an error?
Error at line obj1.x=10;
Error at line obj1.y=8;
Error at line Dim obj1,obj2 as A
Error at line Private x As Integer
For the following program segment: Class A Private x As Integer Public y As Integer End Class Sub Main() Dim obj1, obj2 As New A() obj1.x = 10 obj2.y = 8 End Sub The error at obj1.x=10. What is the cause of this error?
Cannot access the private component of the class.
x is not declared.
Cannot determine the value of x.
Must be called through the class name, not through the object name.
What is a public component of a class?
Allows access from both inside and outside the class and allows inheritance.
Does not allow access from outside the class, only methods inside the class can access it.
Does not allow access from outside the class but allows inherited classes to access it.
Allows access from outside the class.
When declaring properties and methods of a class with the keyword Dim, what is the access scope?
private
public
protected
The program will error and require one of the three keywords.
What is a constructor in VB.Net?
Has the name New, may or may not have arguments.
Has the same name as the class.
Can only build one constructor.
Built inside h
What is the result of the following code? Console.WriteLine(arr.x) after executing the method cal with item 2.
4
2
0
8
How can you declare an array of 10 students in VB.Net?
Dim mang(10) As SinhVien
Dim mang[10] As SinhVien
Cannot declare an array of objects
SinhVien mang(10)
What is the result when running the following code? p.f2() after creating a new Dog object.
Error on line 'Implements Ianimals'
Prints 'Dog'
Error on line 'p.f2()'
Prints nothing.
What will be displayed if obj3.SomeMethod() is called?
BaseClass definition
DerivedClass definition
Error.
Prints nothing.
How to declare inheritance in VB.Net?
What keyword is used to declare inheritance in VB.Net?
inherits
extends
Use the :
No correct answer.
To declare a constructor with a default parameter b = 6 for a rectangle class created by two sides a, b, how should it be declared?
Public Sub New(a As Integer, Optional b As Integer = 6)
Public Sub New(Optional a As Integer, Optional b As Integer = 6)
Public Sub New(a As Integer, b As Integer = 6)
Public Sub New(Optional a As Integer= 6, b As Integer = 6)
In the fraction class, what does the following method declaration mean? Public Sub New(Optional tu As Integer = 1, Optional mau As Integer = 3) Me.tu = tu Me.mau = mau End Sub
Constructor with default parameters of the PhanSo class.
Copy constructor of the PhanSo class.
Assignment method of the PhanSo class.
The declaration cannot exist in the PhanSo class.
In the following program: Public Class PhanSo Private tu, mau As Integer Public Sub New(tu As Integer, mau As Integer) Me.tu = tu Me.mau = mau End Sub Public Sub Xuat() Console.WriteLine(a & '/' & b) End Sub End Class Sub Main() Dim ps1 As New PhanSo() ps.Xuat() End Sub, why does the declaration 'Dim ps1 As New PhanSo()' report an error?
Calling the constructor without parameters while the program has not built it.
The program cannot be wrong because VB.Net will automatically generate a parameterless constructor.
Cannot determine which constructor to call.
All are incorrect.
A method in a subclass that has the same name and return type as a method in its superclass is called?
Method overriding.
Method overloading.
Method hiding.
Method shadowing.
How to declare an abstract method?
Public MustOverride Sub Sound()
Public abstract Sub Sound()
Public MustOverride Sub Sound()
public Overrides Sub Sound()
What is the output of the following code? Dim v As New Vehicle() Dim c As New Car() v.drive() c.drive() v = c v.drive()
Vehicle: drive Car: drive Vehicle: drive
Compile error at line v = c
Runtime error at line v = c
Vehicle: drive Car: drive Car: drive
What is the output of the following code? Dim v As New Vehicle() Dim c As New Car() v.drive() c.drive() c = v c.drive()
Runtime error at line v = c
Vehicle: drive Car: drive Vehicle: drive
Compile error at line v = c
Vehicle: drive Car: drive Car: drive
Which statement is false?
An object of an abstract class can be instantiated.
Any class containing an abstract method must be declared with the MustInherit keyword.
An abstract class can contain one or more abstract methods.
An abstract class can be inherited.
What can multiple inheritance in VB.Net be achieved by?
Interfaces.
Multithreading.
Abstract methods.
Class.
What is the output of the following code? Dim p As New Student() p.output()
Meggies001
Compile Error.
Runtime Error.
Nothing printed.
Which statement about Interface is incorrect?
A class cannot implement multiple interfaces.
Interface is used to achieve multiple inheritance in VB.Net.
An object of an interface cannot be instantiated.
An interface can inherit multiple interfaces.
Which statement is used to add a new item to ListBox?
A. ListBox1.Items.Add("xin chao")
B. ListBox1.AddNewItem("Xin chao")
C. ListBox1.Items.AddNew("Xin chao")
D. None of the answers are correct.
What is the purpose of the Visible property of objects?
A. To prevent moving controls
B. To display images
C. To allow text input
D. To hide or show controls
To make the image size fit the PictureBox, which property is used?
A. SizeMode
B. Image
C. Size
D. MaximumSize
To allow the image size to fit the PictureBox, which property do we use?
SizeMode
Image
Size
MaximumSize
Which control is used to group related information together?
Form
Panel
Combobox
GroupBox
To delete the current image in the PictureBox object, which command do we use?
PictureBox1.Image=null
PictureBox1.Image= ""
PictureBox1.FromFile=null
None of the answers are correct
Which object allows creating multiple working pages in a Form window?
TreeView
Listview
TabControl
Combobox
Which object belongs to the Containers group on the toolbox?
Combobox
Listbox
Panel
Label
The unselected line in the ListBox has what index value?
-1
0
1
Any value
What is a ComboBox?
It is a control that allows data entry and selection.
It is a control that allows viewing information.
It is a control similar to ListBox.
None of the answers are correct
How many types does a ComboBox have?
1
2
3
4
Which control allows users to input date values in the required format?
TextBox
DateTimePicker
ComboBox
MonthCalendar
Which control is used to select a date?
DateTimePicker
MonthCalendar
None of the answers are correct
The FirstDayOfWeek property of the MonthCalendar control has a default value of which day?
Saturday
Sunday
Monday
None of the answers are correct
Which property allows changing the background color of the Panel control?
BackColor
BorderStyle
BackGround
None of the answers are correct
Which statement is correct?
Timer control is only for application developers.
Timer control is invisible during runtime.
Timer control triggers events at specific intervals.
All answers are correct
What can RichTextBox do?
Display many types of documents with font formatting, images, document styles.
Only display text and cannot format.
Only used to display text and format font.
Used to display images.
What is the ProgressBar control?
A control that allows displaying the progress of execution.
A control that allows displaying a list of directories.
A control for executing progress.
A control that displays error messages of the program.
How is the Name property of controls named?
Names must not exceed 20 characters.
Names must start with cmd, txt, lbl...
Cannot contain spaces, written without accents.
How should the Name property of controls be named?
The name should not exceed 20 characters
The name should start with cmd, txt, lbl...
It should not contain spaces, use Vietnamese without accents, and no special characters
It can be named freely as long as it has meaning
Which control is used to create a directory tree?
Timer control
RichTextBox control
TreeView control
ProgressBar control
To display the progress of execution, which control should be selected?
RichTextBox control
TreeView control
ListView control
ProgressBar control
What does the command lstMyListView.items.Clear() do?
Deletes all items in ListView.
Deletes any item in ListView
Selects an item and displays it in ListView
No correct answer.
What is a syntax error?
This error occurs due to incorrect language structure
Occurs unexpectedly while the program is running.
An error due to incorrect thinking leading to wrong results
An error caused by hardware
How to handle syntax errors?
This error can be caught by the code editor, the programmer corrects the syntax.
Error trapping and using error handling structures
Run the program multiple times with different results to see if it fits
Delete the erroneous code and rewrite it
Choose the best answer about the result of executing the following statements? Dim objListView as ListViewItem objListView = lstMyListView.Items.Add("Hi",0) objListView.SubItems.Add("Display")
Add item
Delete item
Add item and subitem to ListView
Select an item and display it in ListView
The Enabled property of the Timer object set to True means?
The Timer object is running
The Timer object is not running
Turn off the Timer object
All answers are correct
Which statement is correct about the timer object?
Timer control is hidden during the application run.
The timer object is visible during the run
The visibility of the timer object is set by the programmer
Which statement about RichTextBox is correct?
RichTextBox is an extended TextBox
RichTextBox is an area for text editing
RichTextBox provides more formatting capabilities than TextBox
All three answers are correct
What does the following code do? If lstMyListView.selectedItems.Count > 0 Then MessageBox.Show (lstMyListView.selectedItems (0).Text) End If
Add item
Delete item
Add item and subitem to ListView
Select an item and display it in ListView
What does the following code do? tvwLanguages.Nodes.clear()
What does the following code do? tvwLanguages.Nodes.clear()
Clear all nodes in TreeView
Delete selected node
Add an object
Edit nodes in TreeView
Which control is commonly selected to execute a task?
RichTextBox
TreeView
ListView
Button
Which property allows hiding/showing a control on the form when the program runs?
Visible
Enable
Name
Font
Which method is used to display a Dialog?
ShowDialog()
DisplayDialog()
Show()
Display()
Which control allows the user to check and open an existing file?
OpenFileDialog
SaveFileDialog
FontDialog
FolderBrowserDialog
Which property of the SaveFileDialog control specifies whether to prompt the user to create a file if it does not exist?
OverwrirePrompt
CreatePrompt
OpenPrompt
Prmpt
Which property of the ColorDialog control displays all basic color dialog boxes?
ShowColor
CustomColors
Color
AnyColor
What is the correct syntax for displaying a message?
MessageBox.Show("Hi there", "Hi")
MessageBox.Show(Hi there, Hi)
MessageBox.Show "Hi There", "Hi"
MessageBox.Show Hi There, Hi
Which statement is used to disable the mnuFilePrint object?
mnuFilePrint.Disabled = True
mnuFilePrint.Enabled = False
mnuFilePrint.Available = False
Disable mnuFilePrint
Which property determines the type of file displayed in the Open or Save As dialog?
FileTypes
Filter
Types
FileDisplay
When a user selects a file in the Open or Save As dialog, where is the file path and name stored?
Filename
PathName
File
Item
Which property initializes the first directory path when opening the Open or Save As dialog?
InitialDirectory
InitialFolder
Location
Path
How many menus can be created in VB.Net?
10
7
11
8
How many types of Dialog are there in the Dialog Category in the Toolbox?
3
5
7
4
Which control in the Toolbox is used to create menus on Windows Form?
Menu control
Menu Strip control
Form control
Menu properties
The list of items displayed in each menu is called:
Items
Menu list
Menu items
Lists
Which property is used by the programmer to reference each menu in the code?
Text
Code
Name
Element
Each Menu Title will have a unique (a) ?
Which property is used by programmers to reference each menu in the code?
Text
Code
Name
Element
Each Menu Title will have a unique ________________?
Access key
Property
Caption
What are the 2 controls needed when creating a toolbar?
Only toolbar control
ImageList and Toolbar Control
Both A and B
All of the above
SqlConnection is an object used to?
Create a connection to the database on SQL Server
Execute a query
Read the returned data
Create a connection to the Access database
To fill data into the dataGridView control, you declare the statement
dataGridView1.DataSource = data source
dataGridView1.DataMember = data source
dataGridView1.RowSource = data source
None of the answers are correct
What parameters do we need when initializing an object of the SqlConnection class?
server; database, integrated security
server; password; database
database; integrated security; password
server; database; username
To execute Insert statements, which method do we use in VB.NET?
ExecuteNonQuery()
ExecuteReader()
ExecuteScalar()
EndExecuteNonQuery()
To execute a Select query, which statement do we use?
ExecuteReader()
ExecuteNonQuery()
ExecuteScalar()
EndExecuteReader()
Which line is incorrect in the following statement?
Dim ketnoi = new SqlConnection(@server=(local);database=Quanlysinhvien; integrated security=true;);
Dim truyvan = select * from sinhvien;
Dim cmd = new SqlCommand(ketnoi);
Dim da = new SqlDataAdapter(cmd);
Which line is incorrect in the following statement?
Dim ketnoi = new SqlConnection(@server=(local);database=Quanlysinhvien; integrated security=true;)
Dim truyvan = select * from sinhvien
Dim cmd = new SqlCommand(truyvan,ketnoi)
cmd.ExecuteNonQuery()
Which line is incorrect in the following statement?
Dim ketnoi = new SqlConnection(@server=(local);database=Quanlysinhvien; integrated security=true;)
Dim truyvan = delete from sinhvien
Dim cmd = new SqlCommand(truyvan,ketnoi)
cmd.ExecuteReader()
To use SqlConnection and SqlCommand objects, which library must you declare?
Imports System.Data.SqlClient
Imports System.Data
Imports System.Data.SqlClient.Data
Imports System.Data.OLEDB
To open a connection to the Server, which method do we use?
(a)
Which library do we import?
Imports System.Data.SqlClient
Imports System.Data
Imports System.Data.SqlClient.Data
Imports System.Data. OLEDB
To open a connection to the Server, which method do we use?
ketnoi.Open()
ketnoi.OpenConnection()
ketnoi.OpenDatabase()
None of the answers are correct
To get the current row index in DataGridView, which command do we use?
dataGridView1.CurrentRow.Index
dataGridView1.CurrentCell.Index
dataGridView1.CurrentRow.Count
None of the answers are correct
To get the value of the currently selected cell (the current row is the first row), which command do you choose in dataGridView?
DataGridView1.CurrentRow.Cells(0).Value
dataGridView1.CurrentRow.Cells[0].Text
dataGridView1.CurrentCell.Row[0].Value
dataGridView1.CurrentRow.Row[0].Value
To get the value of the second column in the third row in dataGridView, which command do you choose?
dataGridView1.Rows[2].Cells(1).Value
dataGridView1.CurrentRow[2].Cells[1].Value
dataGridView1.Cells[2].Rows[1].Value
None of the answers are correct
What does the following code do? dataGridView1.Rows(current).Selected = false current = 0 dataGridView1.Rows(current).Selected = true
Moves to the first record
Moves to the last record
Moves to the record behind the current record
Moves to the record in front of the current record
What does the following code do? if current >dataGridView1.Rows.Count-1 then return end if dataGridView1.Rows(current).Selected = false current = current + 1 dataGridView1.Rows(current).Selected = true
Moves to the record after the current record
Moves to the first record
Moves to the record in front of the current record
Moves to the last record
What does the following code do? if current <= 0 then return end if dataGridView1.Rows(current).Selected = false current = current-1 dataGridView1.Rows(current).Selected = true
Moves to the record before the current record
Moves to the last record
Moves to the record behind the current record
Moves to the first record
What does the following code do? if dataGridView1.Rows(current).IsNewRow then return end if
