Вы находитесь на странице: 1из 15

BCA Revamped PROGRAMME Vth SEMESTER

ASSIGNMENTS-01
Name Register no. Learning center Learning center code Course / Program Semester Subject code Subject Title Date of submission Date of submission Marks awarded : : : : : : : : : : :

Average marks of both assignments

Signature of center coordinator

Signature of Evaluator

Directorate of Distance Education Sikkim Manipal University II Floor, Syndicate House, Manipal-576 104

1. Describe the process of compiling and running a visual Basic application. Answer
To start, you use Visual Studio .NET to create a project, which is made of one or more source files that contain Visual Basic statements. Most simple projects consist of just one source file, but more complicated projects can have more than one source file. A project may also contain other types of files, such as sound files, image files, or simple text files. As the figure shows, a solution is a container for projects, which youll learn more about in a moment. You use the Visual Basic compiler, which is built into Visual Studio, to compile your Visual Basic source into Microsoft Intermediate Language. For short, this can be referred to as Intermediate Language (or IL). At this point the Intermediate Language is stored on disk in a file thats called an assembly. In addition to the IL, the assembly includes references to the classes that the application requires. The assembly can then be run on any PC that has the Common Language Runtime installed on it. When the assembly is run, the CLR converts the Intermediate Language to native code that can be run by the Windows Operating System. CLR is available for Unix System also, i.e. Mono. It is possible that the CLR will eventually be available for other operating systems as well. In other words, the Common Language Runtime makes platform independence possible. Visual Basic applications will be able to run on those operating systems as well as Windows/Unix operating systems. Whether this will happen and how well it will work remains to be seen.

2. Explain various basic data types and variables in visual. Answer


There are two kinds of data types in VB.Net (i) Value type (implicit data types, Structure and Enumeration) (ii) Reference Type (objects, delegates) Value types are passed to methods by passing an exact copy while Reference types are passed to methods by passing only their reference (handle), Implicit data types are defined in the language core by the language vendor, while explicit data types are types that are made by using or composing implicit data types. As seen in the first unit, implicit data types in .net compliant languages are mapped to types in Common Type System (CTS) and CLS (Common Language Specification). Hence, each implicit data type in VB.Net has its corresponding .Net type. The implicit data types in VB.Net are:

Implicit data types are represented in language using keywords; so each of above is a keyword in VB.Net (keyword are the words defined by the language and can not be used as identifiers). It is worth-noting that string is also an implicit data type in VB.Net, so String is a keyword in VB.Net. Last point about implicit data types is that they are value types and thus stored at the stack, while user defined types or referenced types are stored at heap. Stack is a data structure that store items in last in first out (LIFO) fashion. It is an area of memory supported by the processor and its size is determined at the compile time. Heap is the total memory available at run time. Reference types are allocated at heap dynamically (during the execution of program). Garbage collector searches for non-referenced data in heap during the execution of program and returns that space to Operating System.

Variables During the execution of program, data is temporarily stored in memory. A variable is the name given to a memory location holding particular type of data. So, each variable has associated with it a data type and value. In VB.Net, a variable is declared as: Dim<variable> as <data type> Example: Dim I As Integer The above line will reserve an area of 4 bytes in memory to store integer type values, which will be referred in the rest of program by identifier i. You can initialize the variable as you declare it (on the fly) and can also declare/initialize multiple variables of same type in a single statement. Examples: Dim isReady As Boolean = True Dim percentage = 87.88, average = 42.5 As Single Dim digit As Char = 8c

3. With the help of suitable example, describe the development of single document and multi-document interface. Answer
With the example of the two versions of the Financial Calculations application, we can describe the development of single document and multi-document interface. These applications let the user calculate an investment or depreciation using forms. Also, each application includes a third form that provides a way for the user to access the other forms. Single Document Interface: In an SDI application, each form runs in its own application window, and this window is usually shown in the Windows taskbar. To switch between the open forms, the taskbar buttons are clicked. In this interface, each form can have its own menus and tools. A main form called startup form provides access to other forms. Example: Fig. SDI

Multi-Document Interface: In an MDI application, a container form called a parent form contains one or more child forms. Then, the menus and toolbars on the parent form contain the commands that make opening and viewing of forms possible. Its Window menu is used to switch between the open forms. When the parent form is closed, all of its child forms are closed.

4. Describe the concept of exception in .Net environment. Answer


Exception in .NET: The common language runtime in .NET does not error codes. When an unexpected condition occurs, the CLR creates a special object called an exception. This object contains properties and methods that describe the unexpected condition in detail and communicate various items of information about what went wrong. This is why, instead of using error handling, .NET uses the term 'exception handling'. It refers to the techniques used in .NET to detect exceptions and take appropriate actions. .NET implements a system wide, comprehensive approach to exception handling. The exception object containing error information is an instance of a class that derives from a class name System.Exception. A variety of subclasses of System.Exception are used for different circumstances. Exception Handling Keywords: Some keywords are used in exception handling like: 1. Try: Begin a section of code that might contain the error code. The exception is automatically routed to the Catch block. 2. Catch: Begins an exception handler for a type of exception. One or more Catch block follow a try block and each catch block handles different exceptions. 3. Finally: It contains codes that must be run regardless of the exception detected. Typically, it is used to close or dispose of any resources that might have been left unresolved by the error code. 4. Throw: It generates an exception. It is usually done in a Catch block when the exception should be kicked back to a calling routine or in a routine that has itself detected an error.

5. Explain the concept of setting a connection string with example. Answer


There are Properties and Methods associated with the Connection Object, of course. We want to start with the Connection String Property. This can take MANY parameters. Fortunately, we only need a few of these. We need to pass two things to our new Connection Object: the technology we want to use to do the connecting to our database; and where the database is. (If your database was password and user name protected, you would add these two parameters as well. Ours isnt, so we only need the two.) The technology is called the Provider; and you use Data Source to specify where your database is. This should be entered on the same line, and not two as it is below. So add this to your code: Con.ConnectionString = PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\AddressBook.mdb Notice the two parts, separated by a semi-colon: 1st part: PROVIDER=Microsoft.Jet.OLEDB.4.0 2nd Part: Data Source = c:\AddressBook.mdb The first part specifies which provider technology we want to use to do the connecting (JET). The second part, typed after a semi-colon, points to where the database is. In the above code, the database is on the C drive, in the root folder. The name of the Access file we want to connect to is called AddressBook.mdb. (Note that Data Source is two words, and not one.) But your coding window should now look like this: Private Sub btnLoad_Click(ByVal sender as Object,_ By Val e as System.EventArgs)_ Handles btnLoad.Click Dim con as new OleDb.OleDbConnection Con.ConnetionString = Provider = Microsoft.Jet.Oledb.4.0; DataSource = C:\AddressBook.mdb This assumes that you have copied the AddressBook database over to the root folder of your C Drive. If youve copied it to another folder, change the Data Source part to match. For example, if you copied it to a folder called databases youd put this:

Data Source = C:\databases\AddressBook.mdb In our code, though, ConnectionString is a property of the con variable. The con variable holds our Connection Object. Were passing the Connection String the name of a data provider, and a path to the database.

1. What are syntax rules for writing XML file? Explain XML entities.

Answer
The syntax rules of XML are very simple and logical. The rules are easy to learn, and easy to use. 1. XML consist of user-defined tags. Ex : < address>Hyderabad </address> < state >AP</state> < city >HYD</city> 2. We can describe the XML with the tags. 3. In XML file each & every tag must have an ending tags Ex: <student> </student> To create the empty tags we use a single tag or a single line statement. < student /> ( i.e., < student > < /student > ) 4. XML is case sensitive Ex 1: The below is the invalid XML file, because the in the starting element (i.e <student>) s is small and in the ending tag S is capital. < student > < /Student > Ex 2: The below is the valid XML < student > < /student > 5. We cant create an XML file without a root element . Ex: In the below student.xml file <student> is the root element. <student> <sno>1</sno> <sname>a</sname> <saddr>Hyderabad</saddr> </student> 6. In XML we need to use only proper nesting. Ex: The below is the valid XML file <student> <sno>1</sno> </student> Ex: The below is the invalid XML file, because of improper nesting. <student> <sno>1 </student> </sno> 7. In XML we use the comments as follows <! - -Comment - -> 8. When we are declaring the attributes each and every attribute value must be enclosed with in the single quotes (or) double quotes. Ex: <student sno=1> </student> (or) <student sno=1></student>

9. Element: An element consist of a) Simple Content b) Mixed Content c) Complex Content a) Simple Content: Simple content consists of some text in between the tags. Ex: <address> this is address</address> b) Mixed Content: Mixed content consists of simple content and attributes. Example: <address attr=some_value> this is address </address> c) Complex Content: Comple content consist of another tag Example: <student> <sno attr=some_value> Content </sno> </student> Example: <student> <sno>1</sno> <sname>aaa</sname> <marks>23</marks> <address>bb</address> </student>

2. What are the methods and properties of XML DOM ? Explain with examples. Answer
Properties and methods define the programming interface to the XML DOM. The DOM models XML as a set of node objects. The nodes can be accessed with JavaScript or other programming languages. In this tutorial we use JavaScript. The programming interface to the DOM is defined by a set standard properties and methods. Properties are often referred to as something that is (i.e. nodename is "student"). Methods are often referred to as something that is done (i.e. delete "student"). XML DOM Methods: x.getChildNodes Returns a list of all of the children of the current node. This is returned as a Node List object which has its own methods. x.getFirstChild Returns the first child of the current node. x.getLastChild Returns the last child of the current node. x.getPreviousSibling Returns the node immediately before the current node x.getNextSibling Returns the node immediately after the current node x.getAttributes Returns a NamedNodeMap containing the attributes of the current node. x.insertBefore (newnode, refnode) Inserts the new node immediately before the current node which is passed as the refnode parameter. x.replaceNode (newnode, oldnode) Replaces the node in its second parameter with that in its first. x.removeChild (child) Removes the child node from the tree. x.appendChild (child) Appends the child to the end of the list of children of the current node. x.getElementsByTagName (tag) Returns all elements which have the name supplied as a parameter. To return all of the elements in a tree, use the parameter *. The parameter is a string which must be quoted. XML DOM Properties: These are some typical DOM properties: x.nodeName - the name of x x.nodeValue - the value of x x.parentNode - the parent node of x x.childNodes - the child nodes of x x.attributes - the attributes nodes of x

Note: In the list above, x is a node object. Examples Example 1: Access a node using its index number in a node list. This example uses the getElementsByTagname () method to get the second <sname> element in "college.xml <html> <head> <script type="text/javascript" src="loadxmldoc.js"></script> </head> <body> <script type="text/javascript"> xmlDoc=loadXMLDoc("college.xml"); x=xmlDoc.getElementsByTagName("sname"); document.write(x[2].childNodes[0].nodeValue); </script> </body> </html> OUTPUT: Rani Example 2: This example uses the nodeType property to get node type of the root element in "college.xml". <html> <head> <script type="text/javascript" src="loadxmldoc.js"></script> </head> <body> <script type="text/javascript"> xmlDoc=loadXMLDoc ("college.xml"); document. write (xmlDoc.documentElement.nodeName); document. write ("<br />"); document.write(xmlDoc.documentElement.nodeType); </script> </body> </html> OUTPUT: College 1 NOTE: The above two examples can be saved with the extension .html.

3. Explain XML schema. What are the disadvantages of DTD? Answer


XML Schema includes constructors that help us to prepare XML markup language specifications, alternative to DTD. The XML Schema language is also referred to as XML Schema Definition (XSD). The disadvantages of DTD: o While specifying the child elements in DTD it can only use /,* (or) + to describe the occurrence. But in most of the cases we want to describe the exact number for the lower and upper limit. Like we may want the emps element to have minimum 5 emp elements and maximum 20. o DTD does not have a support for common and simple types instead it provides only PCDATA. o DTD does not support XML namespace. o In case of DTD the element definition name and the element name is same.

4. What is XPath ? explain XPath string functions with examples? Answer


An XPath expression returns either a node-set, a string, a Boolean, or a number.

String Functions
Functions starts-with(string1, string2) contains(string1, string2) substring(stringoffsetlength) substring-before(string1, string2) string-length(string) normalize-space(string) translate(string1, string2, string3) concat(string1, string2, ...) format-number(number1, string1, string2) Description Returns true if the first string starts with the second string. Returns true if the first string contains the second string. Returns a section of the string. The section starts at offset (which is a number), and is as long as the value provided at length (also a number). Returns the part of string1 up until the first occurrence of string2. Returns the length of string (i.e. the number of characters). Trims the leading and trailing space from string. Also replaces consecutive occurrences of white space with a single space. Returns string1 after any matching characters in string2 have been replaced by the characters in string3. Concatenates all strings (i.e. joins them together). Returns a formatted string version of number1 after applying string1 as a format string. string2 is an optional locale string.

substring-after(string1, string2) Returns the part of string1 after the first occurence of string2.

5. What is DOM? Draw the DOM tree for emp.xml. Answer


The XML DOM defines a standard way for accessing and manipulating XML documents. The DOM presents an XML document as a tree-structure. Knowing the XML DOM is a must for anyone working with XML.

Вам также может понравиться