Your contribution can guide someone’s learning journey. Share your
documents today.
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 useredink/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 frameworkin 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 fromSystem.Object. Listone advantage andonedisadvantage 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 asample examonly
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
3.(2 marks) Why is it considered apoorprogramming practice to have a lot ofstatic 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: usingSystem; namespaceExamQuestion { classProgram { staticvoidMain(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 asample examonly
Explanation: According to (Troelsen & Japikse, 2015), This is an empty array which also has empty collection thus must give an empty output.
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 usedata structuresonly for storing data. You have been told that youcannotuse 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
6.(10 marks) Consider the following ADO.NET code snippet and answer the questions that follow: … SqlConnectionconn=null; SqlDataReaderreader=null; stringinputIP="131.170.27.121"; try { conn=newSqlConnection("some connection string"); conn.Open(); SqlCommandcmd= AnewSqlCommand("select * from log where ip =@IP",conn); SqlParameterparam=new SqlParameter(); param.ParameterName= "@IP"; param.SqlDbType=SqlDbType.VarChar; Bparam.Size=15; param.Direction=ParameterDirection.Input; param.Value=inputIP; cmd.Parameters.Add(param); reader=cmd.ExecuteReader(); … } 5 This is asample examonly
a.(2 marks) The namespaceSystem.Data.SqlClientis 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 thespecialname 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. SqlParameterparam=new SqlParameter(); -this is the declaration of parameter object. param.ParameterName= "@IP"; -definition ofa 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 themaximum length of arequestthat is senttoa URL. param.Direction=ParameterDirection.Input; -this setsa value that indicates that the parameter is input-only. param.Value=inputIP; -this allocates the valueof the variable bound to the parameter. 6 This is asample examonly
7.(3 marks) Consider the following C# code snippet and answer the questions that follow: classProgram { staticvoidMain(string[]args) { WishIAttendedTheLecturessigh=new WishIAttendedTheLectures(); Console.WriteLine("4+2="+sigh.Add(4,2)); Console.WriteLine("4-2="+sigh.Sub(4,2)); } } publicinterfaceIMath { doubleAdd(doublex, doubley); doubleSub(doublex, doubley); } classMath:IMath { publicdoubleAdd(doublex,doubley){returnx+y;} publicdoubleSub(doublex,doubley){returnx-y;} } classWishIAttendedTheLectures:IMath { privateMath_math= newMath(); publicdoubleAdd(doublex,doubley) { return_math.Add(x,y); } publicdoubleSub(doublex,doubley) { return_math.Sub(x,y); } } Whichpatternis 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.
What advantages does its use offer? List anythree. 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 TOSECTIONB 8 This is asample examonly
Section B/ ASP.NET Core [50 marks] 8.(5 marks = 1 + 1 + 1 + 1 + 1) Complete the entries in Column B-one of them hasbeen completed for you: Column AColumn B a.Data validation codeis found in Model class/file. b.Foreign key constraint is found inData set in mdf database. c.Composite key constraint is found intable of a sql server. d.Route constraints at a global levelare found inGlobal.asax.file e.Connection string to database is found inWeb.configfile f.Web server startup code is found inweb.xml file 9 This is asample examonly
9.(5 marks = 1 + 1 + 1 + 1 + 1) Explain in a sentence or two, the followingEntity Framework (EF)Core queries,one of them has been explained for you: EF Core QueryExplanation a.using(varcontext =newLoading all the data BloggingContext())from ‘Blogs’ table in {a database. This is varblogs=equivalent to acontext.Blogs.ToList();SELECT * FROM}sql query. b.using(varcontext =new BloggingContext()) Loading of list of entities { varblog=context.Blogs .Single(b=>b.BlogId==1); } c.varproducts=context.Prducts.Where (p=>p.CategoryId ==1&& p.UnitsInStock < 10); Querying data using the Dbset d.varauthors=context.Authors .Include(a=>a.Books)Loading related data .ToList(); e.varcars=context.Cars .AsNoTracking() .ToList(); Updating many to many relationship in Dbset f.vatcategories= 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
10.(10 marks) Answer the following questions: a.(3 marks) Listthreeways of error handling in an ASP.NET Core project.There isno need to write any code.Use of try-catch block isnotan 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 asample examonly
11.(10 marks) Consider the following code snippet and answer the questions that follow: @*Thedatareferstothe ‘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 asample examonly
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.
12.(10 marks) Consider the following code snippet and answer the questions that follow: usingMicrosoft.EntityFrameworkCore; namespaceMystery.Models { publicclassSomeContext : DbContext { A B publicDbSet<Product>Products{get;set;} publicDbSet<Store>Stores{get;set;} publicDbSet<OwnerInventory>OwnerInventory{get;set;} publicDbSet<StockRequest>StockRequests{get;set;} publicSomeContext(DbContextOptions<SomeContext> options): base(options){ } C protectedoverride 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 doesDbContext(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 asample examonly
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 usedto 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 asample examonly
13.(10 marks) You were asked to implement asocial media loginin Assignment 2. How did you accomplish the above feature? List the basic steps.There is no needfor 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 TOSECTIONC 16 This is asample examonly
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Section C/ Angular, Case Study [20 marks] 14.(10 marks) Consider the following TypeScript code files and answer the questions that follow: INVOICE.TS namespacedemo{ exportnamespaceinvoiceApp { exportclassInvoice { publiccalculateDiscount(price: number) { returnprice* .40; } } } } INVOICE.TEST.TS varinvoice=newdemo.invoiceApp.Invoice(); console.log(invoice.calculateDiscount(500)); a.(2 marks) Why is theexportkeyword 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 keywordnamespacedo 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 fileInvoice.test.tsto reference the first fileInvoice.ts? namespace Invoice.ts 17 This is asample examonly
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
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. InProceedings 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 asample examonly