KEMBAR78
C# & .NET Programming Errors | PDF | Command Line Interface | Databases
0% found this document useful (0 votes)
105 views4 pages

C# & .NET Programming Errors

This document contains questions to identify errors, outputs, and correct answers related to C# and .NET programming concepts. It includes 10 multiple choice and fill-in-the-blank questions testing knowledge of topics like XML processing, threading, ADO.NET, and ASP.NET. The questions are followed by explanations or answers to check understanding of key concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views4 pages

C# & .NET Programming Errors

This document contains questions to identify errors, outputs, and correct answers related to C# and .NET programming concepts. It includes 10 multiple choice and fill-in-the-blank questions testing knowledge of topics like XML processing, threading, ADO.NET, and ASP.NET. The questions are followed by explanations or answers to check understanding of key concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

S.

Sonali
18ucse036

CS8073 – C# AND .NET PROGRAMMING

ASSIGNMENT – II (UNIT III & IV)


IDENTIFY THE ERROR (Q1, Q2 AND Q3):

1) <script>
var http = new XMLHttpRequest();
http.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
myFunction(this);
}
};
http.open("GET", "books.xml", true);
http.send();
function myFunction(xml) {
var xmlDoc = xml.responseXML;
document.getElementById("demo").innerHTML =
xmlDoc.getElementsByTagName("title")[0].childNodes[0];
</script>

Answer:
var http = new XMLHttpRequest();
http.onreadystatechange = function()
{
if (this.readyState == 4 && this.status == 200)
{
myFunction(this);
}
};
http.open("GET", "books.xml", true);
http.send();
function myFunction(xml)
{
var xmlDoc = xml.responseXML;
document.getElementById("demo").innerHTML =
xmlDoc?.getElementsByTagName("title")[0].childNodes[0];
}

Error:
Line 13 = } Line 12 = ?

2) newNode = xmlDoc.newElement("book");
x = xmlDoc.documentElement;
y = xmlDoc.getElementsByTagName("book")[3];
x.insertBefore(newNode,y);

Error:
Line 1:var,?
Line 2 :var,?
Line 3:var,?

3) x = xmlDoc.getElementsByTagName('title');
xlength = x.len;
for (i = 0; i <xLen; i++) {
txt += x[i].childNodes[0].nodeValue) + " ";

Answer
var x = xmlDoc.getElementsByTagName('title');
var xlength = x.len;
for (var i = 0; i <xlength; i++)
txt += (x[i].childNodes[0].nodeValue) + " ";

Error:

line 1 var
line 2 var
line 3 var, {

IDENTIFY THE OUTPUT (Q4 AND Q5)

4) using System;
using System.IO;
using System.Xml;
public class Sample
{
public static void Main()
{
// Create the XmlDocument.
XmlDocument doc = new XmlDocument();
doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +
"<title>Pride And Prejudice</title>" +
"</book>"); // Save the document to a file.
doc.Save("data.xml");
}
}

Output:
<book genre=”novel” ISBN=”1-861001-57-5”>
<title>Pride And Prejudice</title>
</book>

5) using System;
using System.Threading.Tasks;
namespace TutlaneExamples{
class Program{
static void Main(string[] args){
Task t1 = new Task(PrintInfo);
t1.Run();
Console.WriteLine("Main Thread Completed");
Console.ReadLine();
}
static void PrintInfo(){
for(int i = 1; i <= 4; i++){
Console.WriteLine("i value: {0}", i);
}
Console.WriteLine("Child Thread Completed");
}
}
}
Output:

i value: 1
i value: 2
i value: 3
i value: 4
Child Thread Completed
Main Thread Completed

CHOOSE THE CORRECT ANSWER (Q6, Q7 AND Q8)

6) The data is stored in a Microsoft SQL Server database on a server named Admin and the Database name
is Diploma. You connect to Diploma by using Windows authentication mode.You use a SqlConnection
object to connect to the database. Then which is the correct connection string from below?
a) Data Source=Admin\SQLEXPRESS;Initial
Catalog=Diploma;Integrated Security=True
b) Data Source=Admin/SQLEXPRESS;Initial Catalog=Diploma;Integrated Security=True
c) Data Source=Admin\SQLEXPRESS;Initial Catalog=Diploma;Integrated Security=False
d) Data Source=Admin/SQLEXPRESS;Initial Catalog=Diploma;Integrated Security=False

7) Which ado.net class provide disconnected environment?


a) DataReader
b) DataSet
c) Command
d) SQLCommand

8) Which of these keywords are used to implement synchronization?


a) synchronize
b) syn
c) synch
d) synchronized

9) i) __________object is used to fill a DataSet/DataTable with query results in ADO.net.


ii) WPF separates the appearance of a user interface from its behaviour. The appearance is
generally specified in the __________.

Answer:
1) Data Tables
2) XAML

10) Match the following:


a. Web Form---- i.ascx
b.Web User Control ii. .asmx
c.Web Service iii. .aspx

Answer:
Web Form iii. .aspx
Web User Control i.ascx
Web Service ii. .asmx

You might also like