ProductsLogo
LogoStudy Documents
LogoAI Grader
LogoAI Answer
LogoAI Code Checker
LogoPlagiarism Checker
LogoAI Paraphraser
LogoAI Quiz
LogoAI Detector
PricingBlogAbout Us
logo

IMPORTANT • • • • •.

Verified

Added on  2023/04/21

|19
|2951
|290
AI Summary

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
IMPORTANT
Not reading the examinable material and only practising sample exam is a
REALLY BAD IDEA
Read the examinable lectures first, then only practise this exam
In the final exam, you will be given space in the exam booklet to write
answers
Always state your assumptions, if you are not sure about something. It helps the
marker to understand your thought process
Do not use red ink/pen to write answers or label anything in the exam
Section A/ .NET framework, C# & ADO.NET [30 marks]
1. (4 marks) You have been asked to define the term .NET framework in an interview.
a. (1 mark) How will you define it in few words? Keep your answer to the point.
b. (3 marks) List (do not explain) the components of .NET framework.
a) .NET framework is software which runs on Microsoft windows operating system
b) - XML web services
- Console application
- Windows application
2. (2 marks = 1 + 1) All value types in C# inherit from System.Object. List one
advantage and one disadvantage of this approach.
Advantage – it is used to manage huge software systems and makes it easy to identify errors.
Disadvantage – the classes relation is normally artificial thus making it a bit tricky.
2
This is a sample exam only

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
3. (2 marks) Why is it considered a poor programming practice to have a lot of static
methods in a C# class? (do not just say- static belongs to a class and not object.) Explain
your answer briefly.
Static methods are referred to as Shared methods. When a method is defined as static then the
method now will belong to the type but not the instance. Methods which are static can't be
superseded or reached out through inheritance, (Richter, J. 2017).
4. (6 marks = 3 + 3) Consider the following C# code snippet and answer the question that
follows:
using System;
namespace ExamQuestion
{
class Program
{
static void Main(string[] args)
{
int[] i = new int[0];
Console.WriteLine(i[0]);
}
}
}
What will happen upon compilation of the above code segment?
Explain your answer briefly.
Outcome:
False
3
This is a sample exam only
Document Page
Explanation:
According to (Troelsen & Japikse, 2015), This is an empty array which also has empty
collection thus must give an empty output.
Document Page
5. (3 marks) In assignment 1 you were asked to store all the data in a Microsoft SQL Server
database.
Now consider a scenario where you have been asked to use data structures only for storing
data. You have been told that you cannot use an Array.
Which data structure would you choose? Justify your choice by providing an
example or a diagram.
List < >
Example in diagram

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
6. (10 marks) Consider the following ADO.NET code snippet and answer the questions that
follow:

SqlConnection conn = null;
SqlDataReader reader = null;
string inputIP = "131.170.27.121";
try
{
conn = new SqlConnection("some connection string");
conn.Open();
SqlCommand cmd =
A new SqlCommand("select * from log where ip = @IP",conn);
SqlParameter param = new SqlParameter();
param.ParameterName = "@IP";
param.SqlDbType = SqlDbType.VarChar;
B param.Size = 15;
param.Direction = ParameterDirection.Input;
param.Value = inputIP;
cmd.Parameters.Add(param);
reader = cmd.ExecuteReader();

}
5
This is a sample exam only
Document Page
a. (2 marks) The namespace System.Data.SqlClient is needed to compile the above
code. However, this namespace does not come pre-built with .NET Core framework.
What will you do to resolve this issue?
According to (Lutz & Laplante, 2013), you add the reference needed using the reference
manager in the visual studio.
b. (2 marks) What is the special name for the type of SQL code used in Box A? What
advantage does its use offer?
SQL query
Advantage – According to (Sanderson, S. 2011), the sql query is used to retrieve large
data with a convenient time from the database.
c. (6 marks) What is happening in Box B? Explain the code line by line in your own words.
SqlParameter param = new SqlParameter(); - this is the declaration of
parameter object.
param.ParameterName = "@IP"; - definition of a SqlParameter
instance for each parameter in the SqlCommand object’s SQL command.
param.SqlDbType = SqlDbType.VarChar;- defining the data type for the
parameter.
param.Size = 15; - defining the maximum length of a request that is sent to a URL.
param.Direction = ParameterDirection.Input; - this sets a value that
indicates that the parameter is input-only.
param.Value = inputIP; - this allocates the value of the variable bound to the
parameter.
6
This is a sample exam only
Document Page
7. (3 marks) Consider the following C# code snippet and answer the questions that follow:
class Program
{
static void Main(string[] args)
{
WishIAttendedTheLectures sigh = new
WishIAttendedTheLectures();
Console.WriteLine("4 + 2 = " + sigh.Add(4, 2));
Console.WriteLine("4 - 2 = " + sigh.Sub(4, 2));
}
}
public interface IMath
{
double Add(double x, double y);
double Sub(double x, double y);
}
class Math : IMath
{
public double Add(double x, double y) { return x + y; }
public double Sub(double x, double y) { return x - y; }
}
class WishIAttendedTheLectures : IMath
{
private Math _math = new Math();
public double Add(double x, double y)
{
return _math.Add(x, y);
}
public double Sub(double x, double y)
{
return _math.Sub(x, y);
}
}
Which pattern is being used in the code on page 7?
Abstract Factory pattern.

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
What advantages does its use offer? List any three.
It gives method to code for the interfaces than implementing.
It gets rid of the real implementations classes from the code of client.
It also ensures that code is easy to extent, (Thai & Lam, 2013).
PROCEED TO SECTION B
8
This is a sample exam only
Document Page
Section B/ ASP.NET Core [50 marks]
8. (5 marks = 1 + 1 + 1 + 1 + 1) Complete the entries in Column B- one of them has been
completed for you:
Column A Column B
a. Data validation code is found in Model class/file.
b. Foreign key constraint
is found in Data set in mdf database.
c. Composite key constraint
is found in table of a sql server.
d. Route constraints at a global
level are found in Global.asax.file
e. Connection string to database
is found in Web.config file
f. Web server startup code
is found in web.xml file
9
This is a sample exam only
Document Page
9. (5 marks = 1 + 1 + 1 + 1 + 1) Explain in a sentence or two, the following Entity
Framework (EF) Core queries, one of them has been explained for you:
EF Core Query Explanation
a. using (var context = new Loading all the data
BloggingContext()) from ‘Blogs’ table in
{ a database. This is
var blogs = equivalent to acontext.Blogs.ToList(); SELECT * FROM} sql query.
b. using (var context = new
BloggingContext())
Loading of list of
entities
{
var blog = context.Blogs
.Single(b => b.BlogId == 1);
}
c. var products = context.Prducts.Where
(p => p.CategoryId == 1 &&
p.UnitsInStock < 10);
Querying data using the
Dbset
d. var authors = context.Authors
.Include(a => a.Books) Loading related data
.ToList();
e. var cars = context.Cars
.AsNoTracking()
.ToList();
Updating many to many
relationship in Dbset
f. vat categories =
context.Categories.OrderBy(c =>
cCategoryName).ThenOrderBy(c =>
c.CategoryId);
Querying and sorting in
Dbset

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
10. (10 marks) Answer the following questions:
a. (3 marks) List three ways of error handling in an ASP.NET Core project. There is no
need to write any code. Use of try-catch block is not an acceptable answer.
Configuring a customized exception handling page
Configuring status code pages
Troubleshooting ASP.NET core.
b. (7 marks) How can error pages be customised in an ASP.NET Core project? List the
steps. Why is this customisation needed?
Creating the controller classes
Creating the view for the index actions
Setting a middleware to handle the actions and requests in the line.
Setting up the startup classes in the configure method
11
This is a sample exam only
Document Page
11. (10 marks) Consider the following code snippet and answer the questions that follow:
@* The data refers to the ‘Student’ Model *@
<div>
@using (@Html.BeginForm("Index", "Home", FormMethod.Post))
{
<table>
<tr>
<td>@Html.LabelFor(m => Model.RollNo)</td>
<td>@Html.TextBoxFor(m => Model.RollNo) </td>
</tr>
<tr>
<td>@Html.LabelFor(m => Model.Gender)</td>
<td>Male:@Html.RadioButtonFor(m => m.Gender,
"Male", new { @checked = "checked" })
Female:@Html.RadioButtonFor(m => m.Gender,
"Female", true)
</td>
</tr>
<tr>
<td><input type="submit" value="Submit" />
</td>
</tr>
</table>
}
</div>
a. (2 marks) Where are you most likely to find this code in an ASP.NET Core
project? (Model or View or Controller).
View
b. (2 marks) What will be the file extension of the file where you will find this code?
.aspx
12
This is a sample exam only
Document Page
c. (2 marks) What special feature of ASP.NET Core is displayed in the above code?
Note: this question is not the same as part b above. Part b was about syntax and
this is about feature.
The HTML files
d. (2 marks) Which line must be added to the code shown on the previous page to strongly
type the view?
e. (2 marks) The above code can be re written using an alternate syntax. What is that syntax
called? What advantage does this alternate approach offer? Explain your answer briefly.
Razor syntax
Advantage – it is very light and easy to understand.

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
12. (10 marks) Consider the following code snippet and answer the questions that follow:
using Microsoft.EntityFrameworkCore;
namespace Mystery.Models
{
public class SomeContext : DbContext
{
A
B
public DbSet<Product> Products { get; set; }
public DbSet<Store> Stores { get; set; }
public DbSet<OwnerInventory> OwnerInventory { get; set;}
public DbSet<StockRequest> StockRequests { get; set; }
public SomeContext(DbContextOptions<SomeContext>
options) : base(options){ }
C
protected override void
OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<StoreInventory>()
.HasKey(x => new { x.StoreID,
x.ProductID });
}
}
}
a. (1 mark) Where are you most likely to find the above code?
Is found in the entity framework
b. (3 marks) What role does DbContext (shown inside Box A) class play? Explain your
answer briefly.
It is an interface used between the entity classes and the database. It interacts with the
database.
14
This is a sample exam only
Document Page
c. (3 marks) What is the special name for the declarations shown inside Box B? What
purpose do these solve? Explain your answer.
d.
get,set syntax
They are used to restrict access to sensitive data.
e. (3 marks) What is the special name of the syntax used in Box C? Explain the code in
your own words.
Fluent API syntax
It configures properties of an entity to map it with a db column, (Meijer, Beckman &
Bierman, 2016).
15
This is a sample exam only
Document Page
13. (10 marks) You were asked to implement a social media login in Assignment 2.
How did you accomplish the above feature? List the basic steps. There is no need for
writing code.
Create the app since the app Id is required
we’ll implement login using Facebook. All we need to do is copy and paste the code
provided to us by Facebook to create the Facebook social login and replace the placeholder
with your own Facebook app id.
Testing the implementation process by login in to the system.
PROCEED TO SECTION C
16
This is a sample exam only

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Section C/ Angular, Case Study [20 marks]
14. (10 marks) Consider the following TypeScript code files and answer the questions that
follow:
INVOICE.TS
namespace demo {
export namespace invoiceApp {
export class Invoice {
public calculateDiscount(price: number) {
return price * .40;
}
}
}
}
INVOICE.TEST.TS
var invoice = new demo.invoiceApp.Invoice();
console.log(invoice.calculateDiscount(500));
a. (2 marks) Why is the export keyword need in the first file i.e. Invoice.ts? Explain your
answer.
It is used to show that there are classes or even interfaces which will be used and are
outside the namespace.
b. (2 marks) What does the keyword namespace do in the first file i.e. Invoice.ts?
Explain your answer.
It provides a scope to the identifiers which has names of all types and the methods,
(Wigley at al, 2012).
c. (2 marks) What line must be added to the second file Invoice.test.ts to reference the first
file Invoice.ts?
namespace Invoice.ts
17
This is a sample exam only
Document Page
d. (2 marks) If you were to execute the above code via command prompt/terminal, what
command must be executed?
D:\>node demo.js
e. (2 marks) Why does Angular rely on TypeScript rather than JavaScript?
TypeScript has interface which makes it suitable for angular
15. (10 marks) Case study question
There is no sample question for this. You will be given a case study in the final exam, read it
carefully and answer the questions that follow.
END OF EXAM
Document Page
References
Lutz, M.H. and Laplante, P.A., 2013. C# and the. NET framework: ready for real time?. IEEE
software, 20(1), pp.74-80.
Meijer, E., Beckman, B. and Bierman, G., 2016, June. Linq: reconciling object, relations and xml in
the. net framework. In Proceedings of the 2006 ACM SIGMOD international conference on
Management of data (pp. 706-706). ACM.
Richter, J., 2017. Applied Microsoft. NET framework programming. Microsoft Press.
Sanderson, S., 2011. Pro Asp. net MVC 2 Framework. Apress.
Thai, T. and Lam, H., 2013. . NET framework essentials. " O'Reilly Media, Inc.".
Troelsen, A. and Japikse, P., 2015. C# 6.0 and the. NET 4.6 Framework. Apress.
Wigley, A., Sutton, M., Wheelwright, S., Burbidge, R. and Mcloud, R., 2012. Microsoft. net
compact framework: Core reference. Microsoft Press.
18
This is a sample exam only
1 out of 19
[object Object]

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]