MTA PRACTICE TESTS
Flowchart - Correct Answers -You need to gain a better understanding of the solution
before writing the program. You decide to develop an algorithm that lists all necessary
steps to perform an operation in the correct order. Any technique that you use should
minimize complexity and ambiguity. Which of the following techniques should you use?
Requirements analysis, design, coding, testing, and release - Correct Answers -Arrange
the various activities of an application lifecycle in the order in which they are likely to
occur.
Common Intermediate Language (CIL) - Correct Answers -Which of the following
languages is not considered a high-level programming language?
DataSet - Correct Answers -You are developing an application that needs to retrieve a
list of customers and their orders from a SQL Server database. After the list is retrieved,
you should be able to display this data, even when a connection to the SQL Server is
not available. Which of the following classes should you use to hold the data?
BinaryWriter - Correct Answers -The application you are developing needs to write data
to a flat file that include items such as a five-digit integer key, followed by a 20-character
customer name, followed by two date and time fields. Your solution should be as fast as
possible and should create smallest size data file. Which of the following classes should
you use?
DataSet - Correct Answers -You are developing an application that needs to copy data
from a SQL Server table to a DataSet. Which of the following methods should you use
to copy the data?
void - Correct Answers -You are writing a method named PrintReport that doesn't return
a value to the calling code. Which keyword should you use in your method declaration
to indicate this fact?
switch - Correct Answers -You need to provide complex multi-way branching in your C#
program. You need to make sure that your code is easy to read and understand. Which
of the following C# statements should you use?
,foreach - Correct Answers -You are writing a C# program that iterates through a
collection such as arrays and lists. You need to make sure that you process each item
in the collection once. You also need to ensure that your code is easy to read and
debug. Which of the following C# statements provide the best solution for this
requirement?
long - Correct Answers -You are writing a C# program that needs to manipulate very
large integer values that may exceed 12 digits. The values can be positive or negative.
Which data type should you use to store a variable like this?
Inside the finally block - Correct Answers -You have written a C# method that opens a
database connection by using the SqlConnect object. The method retrieves some
information from the database and then closes the connection. You need to make sure
that your code fails gracefully when there is a database error. To handle this situation,
you wrap the database code in a try-catch-finally block. You use two catch blocks—one
to catch the exceptions of type SqlException and the second to catch the exception of
type Exception. Which of the following places should be the best choice for closing the
SqlConnection object?
do-while statement - Correct Answers -You are writing a C# program and need to select
an appropriate repetition structure for your requirement. You need to make sure that the
test for the termination condition is performed at the bottom of the loop rather than at
the top. Which repletion structure should you use?
for - Correct Answers -You are writing a C# program that needs to iterate a fixed
number of times. You need to make sure that your code is easy to understand and
maintain even when the loop body contains complex code. Which of the following C#
statements provide the best solution for this requirement?
private - Correct Answers -You are developing code for a method that calculates the
discount for the items sold. You name the method CalculateDiscount. The method
defines a variable, percentValue of the type double. You need to make sure that
percentValue is accessible only within the CalculateDiscount method. What access
modifier should you use when defining the percentValue variable?
virtual - Correct Answers -You created a class named GeoShape. You defined a
method called Area in the GeoShape class. This method calculates the area of a
geometric shape. You want the derived classes of GeoShape to supersede this
functionality to support the area calculation of additional geometric shapes. When the
method Area is invoked on a GeoShape object, the area should be calculated based on
the runtime type of the GeoShape object. Which keyword should you use with the
definition of the Area method in the GeoShape class?
sealed - Correct Answers -Suppose that you defined a class Scenario that defines
functionality for running customized pivot transform on large data sets. You do not want
, the functionality of this class to be inherited into derived classes. What keyword should
you use to define the Scenario class?
Create a common interface that all classes implement - Correct Answers -You need to
provide printing functionality to several of your classes. Each class's algorithm for
printing will likely be different. Also, not all the classes have an "is-a" relationship with
each other. How should you support this functionality?
method - Correct Answers -You are writing code for a class named Book. You should
be able to get a list of all books sorted by the author's last name. You need to write code
to define this behavior of a class. Which of the following class elements should you
use?
Create a constructor in the Product class to initialize data members - Correct Answers -
Suppose that you are writing code for a class named Product. You need to make sure
that the data members of the class are initialized to their correct values as soon as you
create an object of the Product class. The initialization code should always be executed.
What should you do?
namespace - Correct Answers -You are developing a C# application. You create a class
of the name Widget. You use some third-party libraries, one of which also contains a
class of the name Widget. You need to make sure that using the Widget class in your
code causes no ambiguity. Which C# keyword should you use to address this
requirement?
The static keyword is used to declare members that do not belong to individual objects
but to a class itself - Correct Answers -You are developing a C# application. You need
to decide whether to declare a class member as static. Which of the following
statements is true about static members of a class?
A class is a concrete instance of an object - Correct Answers -Suppose that you are a
new C# developer and are reviewing object-oriented programming fundamentals. Which
of the following statements is not true?
internal - Correct Answers -You are C# developer who is developing a Windows
application. You develop a new class that must be accessible to all the code packaged
in the same assembly. Even the classes that are in the same assembly but do not
directly or indirectly inherit from this class must be able to access the code. Any code
outside the assembly should not be able to access the new class. Which access
modifier should you use to declare the new class?
abstract - Correct Answers -You are C# developer who is developing a Windows
application. You need to provide a common definition of a base class that can be
shared by multiple derived classes. Which keyword should you use to declare the new
class?
Flowchart - Correct Answers -You need to gain a better understanding of the solution
before writing the program. You decide to develop an algorithm that lists all necessary
steps to perform an operation in the correct order. Any technique that you use should
minimize complexity and ambiguity. Which of the following techniques should you use?
Requirements analysis, design, coding, testing, and release - Correct Answers -Arrange
the various activities of an application lifecycle in the order in which they are likely to
occur.
Common Intermediate Language (CIL) - Correct Answers -Which of the following
languages is not considered a high-level programming language?
DataSet - Correct Answers -You are developing an application that needs to retrieve a
list of customers and their orders from a SQL Server database. After the list is retrieved,
you should be able to display this data, even when a connection to the SQL Server is
not available. Which of the following classes should you use to hold the data?
BinaryWriter - Correct Answers -The application you are developing needs to write data
to a flat file that include items such as a five-digit integer key, followed by a 20-character
customer name, followed by two date and time fields. Your solution should be as fast as
possible and should create smallest size data file. Which of the following classes should
you use?
DataSet - Correct Answers -You are developing an application that needs to copy data
from a SQL Server table to a DataSet. Which of the following methods should you use
to copy the data?
void - Correct Answers -You are writing a method named PrintReport that doesn't return
a value to the calling code. Which keyword should you use in your method declaration
to indicate this fact?
switch - Correct Answers -You need to provide complex multi-way branching in your C#
program. You need to make sure that your code is easy to read and understand. Which
of the following C# statements should you use?
,foreach - Correct Answers -You are writing a C# program that iterates through a
collection such as arrays and lists. You need to make sure that you process each item
in the collection once. You also need to ensure that your code is easy to read and
debug. Which of the following C# statements provide the best solution for this
requirement?
long - Correct Answers -You are writing a C# program that needs to manipulate very
large integer values that may exceed 12 digits. The values can be positive or negative.
Which data type should you use to store a variable like this?
Inside the finally block - Correct Answers -You have written a C# method that opens a
database connection by using the SqlConnect object. The method retrieves some
information from the database and then closes the connection. You need to make sure
that your code fails gracefully when there is a database error. To handle this situation,
you wrap the database code in a try-catch-finally block. You use two catch blocks—one
to catch the exceptions of type SqlException and the second to catch the exception of
type Exception. Which of the following places should be the best choice for closing the
SqlConnection object?
do-while statement - Correct Answers -You are writing a C# program and need to select
an appropriate repetition structure for your requirement. You need to make sure that the
test for the termination condition is performed at the bottom of the loop rather than at
the top. Which repletion structure should you use?
for - Correct Answers -You are writing a C# program that needs to iterate a fixed
number of times. You need to make sure that your code is easy to understand and
maintain even when the loop body contains complex code. Which of the following C#
statements provide the best solution for this requirement?
private - Correct Answers -You are developing code for a method that calculates the
discount for the items sold. You name the method CalculateDiscount. The method
defines a variable, percentValue of the type double. You need to make sure that
percentValue is accessible only within the CalculateDiscount method. What access
modifier should you use when defining the percentValue variable?
virtual - Correct Answers -You created a class named GeoShape. You defined a
method called Area in the GeoShape class. This method calculates the area of a
geometric shape. You want the derived classes of GeoShape to supersede this
functionality to support the area calculation of additional geometric shapes. When the
method Area is invoked on a GeoShape object, the area should be calculated based on
the runtime type of the GeoShape object. Which keyword should you use with the
definition of the Area method in the GeoShape class?
sealed - Correct Answers -Suppose that you defined a class Scenario that defines
functionality for running customized pivot transform on large data sets. You do not want
, the functionality of this class to be inherited into derived classes. What keyword should
you use to define the Scenario class?
Create a common interface that all classes implement - Correct Answers -You need to
provide printing functionality to several of your classes. Each class's algorithm for
printing will likely be different. Also, not all the classes have an "is-a" relationship with
each other. How should you support this functionality?
method - Correct Answers -You are writing code for a class named Book. You should
be able to get a list of all books sorted by the author's last name. You need to write code
to define this behavior of a class. Which of the following class elements should you
use?
Create a constructor in the Product class to initialize data members - Correct Answers -
Suppose that you are writing code for a class named Product. You need to make sure
that the data members of the class are initialized to their correct values as soon as you
create an object of the Product class. The initialization code should always be executed.
What should you do?
namespace - Correct Answers -You are developing a C# application. You create a class
of the name Widget. You use some third-party libraries, one of which also contains a
class of the name Widget. You need to make sure that using the Widget class in your
code causes no ambiguity. Which C# keyword should you use to address this
requirement?
The static keyword is used to declare members that do not belong to individual objects
but to a class itself - Correct Answers -You are developing a C# application. You need
to decide whether to declare a class member as static. Which of the following
statements is true about static members of a class?
A class is a concrete instance of an object - Correct Answers -Suppose that you are a
new C# developer and are reviewing object-oriented programming fundamentals. Which
of the following statements is not true?
internal - Correct Answers -You are C# developer who is developing a Windows
application. You develop a new class that must be accessible to all the code packaged
in the same assembly. Even the classes that are in the same assembly but do not
directly or indirectly inherit from this class must be able to access the code. Any code
outside the assembly should not be able to access the new class. Which access
modifier should you use to declare the new class?
abstract - Correct Answers -You are C# developer who is developing a Windows
application. You need to provide a common definition of a base class that can be
shared by multiple derived classes. Which keyword should you use to declare the new
class?