You are on page 1of 4

Competency Unit: MOCK Exam

TSP
Module
Batch

: Birds A&Z Ltd.


: VI
: ID-ESAD-CS/BAZL-01M/R27/01

Trainee Name

: _____________________

Date
Duration
Total Marks
Trainee ID

: 26-Oct-16
: 90 min
: 100

: ___________________

Marks Rewarded: ___

Q1. What does the SaveChanges method the DbContext class return?
A. It is a void method, it returns nothing
B. It returns Boolean value. True indicates all the modifications that were made to the underlying database are
successful, false indicates failure
C. An integer value reflecting the total number of modifications that were made to the underlying database
D. Entity collection where each Entity has original values
Answer: C
Q2. Which two methods of the DbContext object you can use to insert this entity into the data store?
A. Insert
B. Add
C. Attach
D. AddOrAttach
Answer: B, C
Q3. What is Object-relational impedance mismatch?
A. The mismatch found in between SQL data type and Object Oriented Language data type
B. A set problems encountered in programs written CLR compliant language like C# using data coming from
unmanaged environment
C. A set of conceptual and technical difficulties that are often encountered when a relational database management
system is being used by a program written in an object-oriented programming language
D. None of the above
Answer: C
Q4. ____________is a programming technique for addressing impedance mismatch between an object model and a relational
database schema.
A. ORM (Object-Relational Mapping)
B. OData
C. EntityFramework
D. LINQ
Answer: A [ EntityFramework is Microsoft-centric ORM solution]
Q5. Which loading option in Entity Framework makes query returns the primary or target entity, but related data is not retrieved
and related data is fetch using separate query when a NavigationProperty was accessed?
A. Deferred Execution
B. Lazy Loading
C. Eager loading
D. Explicit Loading
Answer: B [Deferred Execution is not loading option. LINQ, EF uses deferred execution. A query is not executed until you touch
i.e., you access the result.
In short, loading option dictates how related data will be loading.
Lazy Loading Related data is not loaded with main query. When you want to access related data, they are loaded using
separate query
Ex:
var q =(from c in db.Customers
Select c);
It will not load orders. Say you now want
foreach (var c in q)
{
Console.Write(c.Orders.Count();
}
Now it will load orders for each customer using a separate query. If you have 20 customers, 20 new query required!!!!
Eager loading- The target, or primary entity, is retrieved when the query is triggered and the related items come with it.
Explicit loading- you use Load extension method]
Q6. When lazy loading is disabled in Entity Framework conceptual model, which method do you use enables you to execute
queries individually, giving you lazy loading?
A. Fetch
B. Load
C. Execute
D. Include
Answer: B
Q7. You have your DbContext object context. Which one should you use to disable Lazy Loading option?
A. context.LazyLoadingEnabled = false;
B. context.Configuration.LazyLoadingEnabled = false;
C. context.Configuration.Conventions. LazyLoadingEnabled = false;
D. context.Configuration.Set LazyLoadingEnabled (false);
Answer: B
Q8. What are compiled query in EntityFramework?

A. A compiled query is used to cache result for every unique set of parameters.
B. A compiled query is used to cache the query result and cache updated if the data in source store is changed.
C. A compiled query is used to cache the resulting SQL and only the parameters are changed when you run the query.
D. A compiled query converts the resulting SQL to a stored procedure
Answer: C
Q9. What happens if you attempt to Attach an entity to a context when it already exists in the context with an EntityState of
unchanged?
A. A copy of the entity is added to the context with an EntityState of unchanged.
B. A copy of the entity is added to the context with an EntityState of Added.
C. Nothing happens and the call is ignored.
D. The original entity is updated with the values from the new entity, but a copy is not made. The entity has an EntityState
of Unchanged.
Answer: C
Q10. The application youre working on uses the EF to generate a specific DbContext instance. The application enables users
to edit several items in a grid and then submit the changes. Because the database is overloaded, you frequently experience
situations that result in only partial updates. What should you do?
A. Call the SaveChanges method of the DbContext instance, specifying the UpdateBehavior.All enumeration value for
the Update behavior.
B. Use a TransactionScope class to wrap the call to update on the DbContext instance.
C. Create a Transaction instance by calling the BeginTransaction method of the DbContext Database property. Call the
SaveChanges method; if it is successful, call the Commit method of the transaction; if not, call the Rollback method.
D. Use a TransactionScope class to wrap the call to SaveChanges on the DbContext. Call Complete if SaveChanges
completes without an exception
Answer: D
Q11. Which one is generally used in LINQ to Objects or LINQ to XML?
A. IEnumeable
B. IQueryable
C. IListSource
D. IOrderedQueryable
Answer: A
[IEnumerable used in LINQ to Objects or LINQ to XML
IQueryable used in LINQ to Entity Framework, LINQ to DataServices]
Q12. Which interface must be implemented in order for something to be queried by LINQ? A.
A. IEnumerable
B. IEntityItem
C. IDbContextItem
D. IComaparable
Answer: A
Q13. SqlDataAdapter needs an open and available SqlConnection to iterate through data.
A. True
B. False
Answer: B [SqlCommand needs an open and available SqlConnection to iterate through data]
Q14. Which one allows forward-only, read-only data access?
A. DataSet
B. DataTable
C. DataReader
D. DataRow
Answer: C
Q15. Which method of DataAdapter object do you call to populate into a DataTable or DataSet object with data fetched
from database?
A. Add
B. Execute
C. Load
D. Fill
Answer: D
Q16. What are the advantages of a compiled query?
A. None. Every time you run the query you will hit the database.
B. The results of the query are cached making the querying a lot faster.
C. The translation of your query into SQL is cached.
D. None. You cant change any of the parameters you use in a query, rendering the compiled query useless.
Answer: C
Q17. You need to execute the following SELECT query using the COUNT aggregate to determine the total record count in a
table:
SELECT COUNT(*) FROM ExamQuestions;
Which one of the following cannot accomplish that?
A. SqlDataAdapter in conjunction with a SqlDataReader
B. SqlDataAdapter in conjunction with a DataTable
C. SqlDataAdapter in conjunction with a DataSet
D. The SqlDataReader and its ExecuteScalar method
Q18. Which file of Entity Data Model holds the information of the mappings between the entities and the underlying data
store?
A. CSDL

B. SSDL
C. MSL
D. EDMX
Answer: C
Q19. Which of the following is not a valid contract in WCF?
A. ServiceContract
B. OperationContract
C. DataContract
D. ErrorContract
Answer: D [ServiceContract, OperationContract, DataContract, FaultContract]
Q20. Which contract do you use to indicate the runtime that the contained type will be serializable?
A. ServiceContract
B. OperationContract
C. DataContract
D. ErrorContract
Answer: C
Q21. Which actions you must do to create a service?
A. Create .svc file and map service class and set activation
B. Decorate your class or interface definition with the ServiceContract attribute
C. Decorate method that you want to expose as service with OperationContract attribute
D. Create Executable to host the service
Answer: B, C
Q22. What does an end point contain?
A. Address
B. Binding
C. Contract
D. Hosting configuration
Answer: A, B, C [ABC (address+binding+contract)=endpoint]
Q23. Which attribute enable services to communicate failures to the client in a safe, intentional, and mutually acceptable
fashion?
A. ErrorContract
B. ExceptionContract
C. FaultContract
D. FailureContract
Answer: C
Q24. Which one do you use to send errors in executing service operation?
A. Exception
B. ServiceExcetion
C. FaultException
D. Detect the type of exception and throw it
Answer: C
Q25. Which predefined contract do you use with meta data endpoint?
A. IMexExchange
B. IMetadataExchange
C. IMexMetadataExchange
D. IMex
Answer: B
Q26. Which of the following is or are valid metadata endpoint?
<endpoint address=svc binding="basicHttpBinding" bindingConfiguration="" name="WsHttp"
contract="Service.ITestService" />
A. <endpoint binding="mexHttpBinding" bindingConfiguration="" name="Mex" contract="IMetadataExchange" />
B. <endpoint binding="mexTcpBinding" bindingConfiguration="" name="Mex" contract="IMetadataExchange" />
C. <endpoint binding="mexMsmqBinding" bindingConfiguration="" name="Mex" contract="IMetadataExchange" />
D. <endpoint binding=" mexNamedPipeBinding" bindingConfiguration="" name="Mex" contract="IMetadataExchange" />
Answer: B
Q27. Which HTTP method is generally used to update an entity through an REST service?
A. GET
B. POST
C. PUT
D. SEND
Answer: C
Q27. Which HTTP method is generally used to partially update an entity through an REST service?
A. GET
B. POST
C. PUT
D. PATCH
Answer: D
Q28. How do you create a Web API controller?
A. Create a controller class in Controllers folder
B. Create a controller class inheriting from Controller class
C. Create a controller class inheriting from ApiController class
D. None of the above

Answer: C
Q29. You want to want to define multiple actions on a given method or to define an action other than the four default ones.
Which one is the best option?
A. Create a custom route
B. Use AcceptVerbsAttribute
C. Use multiple Http method attributes
D. You cannot do that
Answer: B
Q30. You have a public method in your Web API controller. But you dont want it exposed to clients. What should you do?
A. Make the method private
B. Use Authorize attribute and deny all
C. Use NonAction attribute
D. Ingrore route any url pattern that points to that action
Answer: C
Q31. You are using jQuery $.ajax to get data from a Web API. Which property do you set in ajax option object to pass in ajax
method in order to get JSON data?
A. type: JSON
B. dataType: JSON
C. accept: application/JSON
D. format: JSON
Answer: B
Q32. In Web API, which attribute do you use to specify that that a complex type should be read from the URI instead of the
message body?
A. HttpGet
B. Bind
C. FromUri
D. Accept
Answer: C [public HttpResponseMessage Get([FromUri] Person person) {/* implementation */}]
Q33. What is the role of an action filter in Web API?
A. An action filter is used to apply security constraints to actions.
B. An action filter applies pre-conditions in actions.
C. An action filter modifies the way in which the action is executed.
D. An action filter ensures what to do after an action is executed.
Answer: C
Q34. Which one do you use to send stream data in Web Api?
A. StreamMessage
B. StreamContent
C. PushStreamContent
D. BinaryContent
Answer: C
Q35. What should you do when your Web API will be accessed from a different domain than the API is in?
A. Create a custom filter
B. Allow cross-domain script requests
C. Inspect HTTP request and allowed the domains you want to allow to permit
D. None of the above
Answer: C
Q36. What is the difference between lazy loading and eager loading?
Q37. What is the difference between IEnumerable and IQueryable?
Q38. What is binding of a service? What is binding of a service?
Q39. Explain ABC of service endpoint?
Q40. What is Basic authentication?
Q41. What is XSS? What is CSRF attack?
Q42. What is SQL Injection? How can you prevent SQL Injection?
Q43. What is REST? Write HTTP verbs CRUD actions?
Q44. What is WCF Data Service? What is OData?
Q45. What is Azure Blob storage?

You might also like