Question: Visual Basic Programming for the Windows Environment 1. What two properties of a command object do you always need to set before you call one
Visual Basic Programming for the Windows Environment
1. What two properties of a command object do you always need to set
before you call one of the methods of the command?
A). Connection and CommandType
B). Connection and CommandText
C). CommandText and Parameters
D). Command Type and CommandText
2. Given a SqlCommand object named updateCommand that contains a
valid SQL Update statement, which of the following statements executes
the Update statement and returns the number of rows that were affected
by that statement?
A). Dim count As Integer = updateCommand.ExecuteNonQuery()
B). Dim count As Integer = updateCommand.ExecuteActionQuery()
C). Dim count As Integer = updateCommand.ExecuteScalar()
D). Dim count As Integer = updateCommand.ExecuteQuery()
3. Which of the following statements adds a parameter named userIDParm
to an SQL statement thats stored in a command object named
updateCommand?
A). updateCommand.Add(userIDParm)
B). updateCommand.Parameter(userIDParm)
C). updateCommand.Parameter.Add(userIDParm)
D). updateCommand.Parameters.Add(userIDParm)
4. Which of the following statements is not true about default properties?
A). Default properties can be used without specifying the property
name.
B). Default properties are typically used with classes that represent
collections.
C). Default properties require the use of integer indexes.
D). Default properties have declarations that start with the word Default.
5. When coding a business class, why would you want to throw an
argument exception from a property or method?
A). So that the business class is completely self-contained and doesnt
depend on classes that may be coded by other programmers to
validate data.
B). So that the user interface classes dont have to validate data.
C). Because it is more efficient to throw an exception than it is to
validate data before passing that data to a business class.
D). Because it makes your code easier to read.
6. Operator overloading is typically used to ______________________.
A). redefine the function of an existing operator for a built-in data type
B). define a new operator for a user-defined data type
C). define or redefine the function of an existing operator for a user-
defined data type
D). make an operator unavailable to a user-defined data type
7. The declaration for an event specifies _______________________.
A). the event name and a parameter list
B). a class that will handle the event and the events name
C). the object that will send the event and the events arguments
D). the class that will send the event and the events arguments
8. To start an event, you code __________________________________.
A). just the name of the event
B). the name of the event and its arguments
C). RaiseEvent, the name of the event, and its arguments
D). StartEvent, the name of the event, and its arguments
9. You have coded a statement in a form class which uses a property that
throws an argument exception. If the argument thats passed to it is
invalid, you should _________________________________________.
A). use a Try...Catch statement to catch the exception thats thrown
B). rely on the propertys data validation
C). validate the argument before it is passed to the property so that the
exception is never thrown
D). code an exception handler for the argument thats thrown
10. Which of the following cannot be coded in a derived class?
A). A method that overrides a method in the base class.
B). A call to a constructor of the base class.
C). A new method thats not defined by the base class.
D). A call to a private method of the base class.
11. When used correctly, inheritance can __________________________.
A). make an application run faster
B). make it easier to write the code for the application
C). simplify the overall design of an application
D). eliminate the need for casting
12. A Protected method defined within a base class is available to ______.
A). only the base class
B). only classes derived from the base class
C). both the base class and the classes derived from it
D). neither the base class nor the classes derived from it
13. If the Student class inherits the Person class and Option Strict is on,
which of the following statements is true?
A). You must explicitly cast a Person object to a Student object
whenever a Student object is expected.
B). You must explicitly cast a Student object to a Person object
whenever a student object is expected.
C). You must explicitly cast a Person object to a Student object
whenever a Person object is expected.
D). You must explicitly cast a Student object to a Person object
whenever a Person object is expected.
14. A class can _______________________________________________.
A). have only one derived class
B). be the base class for only one derived class
C). be only a base class or a derived class
D). be both a base class and a derived class
15. Which of the following is not a reason to declare a class as sealed?
A). To prevent others from inheriting the class.
B). To improve efficiency.
C). To prevent others from changing how the methods work.
D). To give a class more functionality.
16. Which of the following is a difference between interfaces and abstract
classes?
A). None of the members of an interface can be implemented, but some
of the members of an abstract class can be.
B). An interface can declare shared members, but an abstract class cant.
C). An interface cant inherit multiple classes, but an abstract class can.
D). All of the above.
17. A method that accepts an interface as an argument can accept any object
that __________________________________________________.
A). implements that interface.
B). defines the same methods as the interface.
C). implements the interface or defines the same methods as the
interface.
D). is created from that interface.
18. A variable which stores an object that implements an interface can be
declared as which of the following data types?
A). The class that defines the object.
B). The interface that the object implements.
C). Any subclass of the class that defines the object.
D). All of the above.
19. Which of the following statements about interfaces is not true?
A). An interface can only declare abstract members.
B). An interface can inherit other interfaces.
C). A class can only implement a single interface.
D). A class that implements an interface must provide an
implementation for every member of the interface.
20. When would you want to code two or more classes in a single file?
A). When the classes are large.
B). When the project contains many classes that are unrelated.
C). When the classes are closely related and small.
D). When the project contains only a few class files.
21. Which of the following is not a benefit of using class libraries?
A). They simplify maintenance.
B). The size of projects that use them is reduced.
C). Their code is reusable.
D). They make it easier for other classes to refer to the classes in the libraries.
22. Before you can use a class library in an application, you must ______.
A). fully qualify each class in the library with its namespace
B). code an Imports statement that identifies the class librarys
namespace
C). add a reference to the class library
D). create a new namespace for the application
23. Partial classes can be used to ______________________________.
A). split the code for a class across two or more namespaces
B). split the code for a class across two or more files
C). hold the code for a class that hasnt been finished
D). hold the code for a class until the other classes in that assembly are
finished
24. To make it easy to test a class library, you can ____________________.
A). make sure that all the classes require only the System namespace
B). put references to all the .NET namespaces in the library
C). add one class to the library at a time
D). develop the class library project within a solution that creates a
Windows Forms project
25. The GetType method of an object returns _____________________.
A). a Type enumeration that identifies the objects type
B). a Type object that contains information about the objects type
C). a string that contains the name of the objects type
D). an integer value that identifies the type of the object
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
