COMPLETE SOLUTIONS, GRADED A+
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? Answer - Flowchart
Arrange the various activities of an application lifecycle in the order in which
they are likely to occur. Answer - Requirements analysis, design, coding,
testing, and release
Which of the following languages is not considered a high-level programming
language? Answer - Common Intermediate Language (CIL)
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? Answer - void
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? Answer - switch
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?
Answer - foreach
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? Answer - long
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? Answer - Inside the finally block
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? Answer - do-while
statement
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? Answer - for
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? Answer - private
, 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? Answer - virtual
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? Answer - sealed
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? Answer - Create a common interface that all classes implement
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?
Answer - method
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? Answer - Create a
constructor in the Product class to initialize data members
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