You are on page 1of 22

AWT SAMPLE PAPER 1 Q. 1 Attempt any four of the following: a)List the different component of .

.Net framework & diagram Ans. Introduction to .NET Framework: (Optional) .NET is a "Software Platform". It is a language-neutral environment for developing rich .NET experiences and building applications that can easily and securely operate within it. NET is implemented instead of targeting a particular Hardware/OS combination. The components that make up the .NET platform are collectively called the .NET Framework. The .NET Framework is a managed, type-safe environment for developing and executing applications. The .NET Framework manages all aspects of program execution, like, allocation of memory for the storage of data and instructions, granting and denying permissions to the application, managing execution of the application and reallocation of memory for resources that are not needed. The .NET Framework is designed for cross-language compatibility. Crosslanguage compatibility means, an application written in Visual Basic .NET may reference a DLL file written in C# (C-Sharp). A Visual Basic .NET class might be derived from a C# class or vice versa. The .NET Framework consists of two main components: Common Language Runtime (CLR) Class Libraries Common Language Runtime (CLR) The CLR is described as the "execution engine" of .NET. It provides the environment within which the programs run. It's this CLR that manages the execution of programs and provides core services, such as code compilation, memory allocation, thread management, and garbage collection. Through the Common Type System (CTS), it enforces strict type safety, and it ensures that the code is executed in a safe environment by enforcing code access security. The software version of .NET is actually the CLR version. Working of the CLR Compiled By Prof. Vaibhav Vasani

When the .NET program is compiled, the output of the compiler is not an executable file but a file that contains a special type of code called the Microsoft Intermediate Language (MSIL), which is a low-level set of instructions understood by the common language run time. This MSIL defines a set of portable instructions that are independent of any specific CPU. It's the job of the CLR to translate this Intermediate code into a executable code when the program is executed making the program to run in any environment for which the CLR is implemented. And that's how the .NET Framework achieves Portability. This MSIL is turned into executable code using a JIT (Just In Time) complier. The process goes like this, when .NET programs are executed, the CLR activates the JIT complier. The JIT complier converts MSIL into native code on a demand basis as each part of the program is needed. Thus the program executes as a native code even though it is compiled into MSIL making the program to run as fast as it would if it is compiled to native code but achieves the portability benefits of MSIL. Class Libraries Class library is the second major entity of the .NET Framework which is designed to integrate with the common language runtime. This library gives the program access to runtime environment. The class library consists of lots of prewritten code that all the applications created in VB .NET and Visual Studio .NET will use. The code for all the elements like forms, controls and the rest in VB .NET applications actually comes from the class library.

Compiled By Prof. Vaibhav Vasani

b)Write program to demonstrate use of class, object, constructor, property in VB.Net Ans. Public Class Demo Dim name As String Public Sub New(ByVal na As String) name = na Console.WriteLine("The name is : " & name) End Sub Public Property pName() As String Get Return name End Get Set(ByVal value As String) name = value End Set End Property End Class Module Module1 Sub Main() Dim obj As New Demo("Payal") Console.WriteLine("The name is : " & obj.pName) obj.pName = "Princess" Console.WriteLine("The name is : " & obj.pName) Console.ReadLine() End Sub End Module c)List & describe meaning of *, ?, + {n,m} qualifier Ans. Qualifiers provide a simple way to specify within a pattern how many times a particular character or a set of characters is allowed to repeat itself. The non-explicit qualifiers are: * :- It describes 0 or more occurrences. + :- It describes 1 or more occurrences. ? :- It describes 0 or 1 occurrence. Explicit qualifiers are positioned following the pattern they apply to, just like regular qualifiers. Explicit qualifiers use curly braces { }, and number values for upper and lower limits within the braces. {n,m} :- Repeat atleast n times but not more than m Compiled By Prof. Vaibhav Vasani

Eg: fo* : foo, foe, fail fo+ : foo, foe, foot fo? : fot, fit ap{ 2,4} : appl, apppy, apppply. d)List all data types supported by VB.Net with their storage by length Ans. Data type Byte Char Integer Double Long Short Single String Date Boolean Object Decimal Size (in bytes) 1 2 4 8 8 2 4 Varies 8 2 4 16 Description 8 bit unsigned integer 16 bit Unicode character 32 bit signed integer 64 bit floating point variable 64 bit signed integer 16 bit signed integer 32 bit floating point variable Non numeric type Date type Non numeric type Non numeric type 128 bit floating point variable. Type System.Byte System.Char System.Int32 System.Double System.Int64 System.Int16 System.Single System.String System.Date System.Boolean System.Object System.Decimal

e)Describe for each loop with example to display content of array of 40 number. Ans. The visual basic collection objects support a special type of loop, the for each.....next loop, which you can use to execute a block of code for each element in the collection instead of executing the block a set number of times. Sometimes, we may not know the exact number of elements in collection or sometimes there may be a huge number of elements, so

Compiled By Prof. Vaibhav Vasani

instead of working with each element, we can directly use for eachnext loop so as to do the work easily. Eg : Array of 40 number. Module Module2 Sub main() Dim arr(40), p, i As Integer 'writing in array For i = 1 To 40 arr(i) = i Next 'displaying the contents of array For Each p In arr Console.WriteLine(p) Next Console.ReadLine() End Sub End Module f)List & describe any 6 feature of DOT NET. Ans. VB.NET provides the easiest, most productive language and tool for rapidly building Windows & Web applications. Some features of VB.Net are as follows: Powerful Windows based application Building Web based application Simplified deployment Powerful, Flexible, Simplified Data access Improved Coding Direct access to the platform Full-object oriented constructs XML Web services Mobile Applications COM Interoperability Reuse existing investments Upgrade wizard 1. Powerful, Flexible, Simplified Data access :You can tackle any data access scenario easily with ADO.Net and data access. The flexibility of ADO.Net enables data binding to any database, as well as classes, collections, and arrays and provides true XML representation of data. Seamless access to ADO enables simple data access for connected data binding scenarios. Using

Compiled By Prof. Vaibhav Vasani

ADO.Net, VB.Net can gain high speed access to Ms SQL server, Oracle, DB2, Microsoft Access and more. 2. Improved Coding:We can code faster and more effectively. A multitude of enhancements to the code editor, including enhance Intellisense, Smart listing of code for greater readability and a background compiler for real time notification of syntax errors transforms into a Rapid Application Development (RAD) coding machine. 3. COM Interoperability:We can maintain our existing code without the need to recode. COM Interoperability enables us to leverage our existing code assets and offers seamless bidirectional communication between VB6.0 and VB.Net applications. 4. Upgrade Wizard:We upgrade our code to receive all of the benefits of VB.Net 2005. The VB.Net upgrade wizard available in VB.Net 2005 standard edition and higher, upgrades up to 95% of the existing VB code and forms to VB.Net with new support for web classes and user controls. Q.2.Answer the following: 1) Write a program for the given figure. Describe different keyword used to construct program.

Student Name, roll no

Marks m1, m2

Result avg, grade ANS: Public Class Student Dim name As String Dim rollno As Integer Public Sub New(ByVal n As String, ByVal r As Integer) name = n rollno = r End Sub Public Sub display()

Compiled By Prof. Vaibhav Vasani

Console.WriteLine("Name: Console.WriteLine("Roll No: End Sub End Class Interface Marks Sub Calculate() Property mark1() Property mark2() End Interface Public Class Result Inherits Student Implements Marks

" & name) " & rollno)

Dim m1, m2, total As Integer Dim avg As Double Dim grade As Char Public Sub New(ByVal n1 As String, ByVal R1 As Integer) MyBase.New(n1, R1) End Sub Public Sub Calculate()Implements Marks.Calculate total = m1 + m2 avg = total / 2 If avg >= 70 Then grade = "A" ElseIf avg >= 50 Then grade = "B" Else grade = "C" End If Console.WriteLine("Mark1 Console.WriteLine("Mark2 Console.WriteLine("Average Console.WriteLine("Grade End Sub

:" :" :" :"

& & & &

m1) m2) avg) grade)

Public Property mark1() As Object Implements Marks.mark1 Get Return m1 End Get Set(ByVal value As Object) m1 = value End Set End Property Public Property mark2() As Object Implements Marks.mark2 Compiled By Prof. Vaibhav Vasani

Get Return m2 End Get Set(ByVal value As Object) m2 = value End Set End Property Public Sub disp() MyBase.display() End Sub End Class Module Module1 Sub Main() Dim res As New Result("Manoj Kavedia", 64) res.mark1 = 95 res.mark2 = 99 res.display() res.Calculate() Console.ReadLine() End Sub End Module

Different Keywords used are: MyBase keyword is used to call methods in a base class when overriding methods in a derived class. Inherits keyword specifies which class is been inherited by the derived one. Implements keyword specifies the interface being implemented by the class. If a class implements an interface then that class has to define all the data members of that interface mandatorily. A Property is a special type of method which is designed to assign and retrieve class data. Properties are nothing but wrapper methods on

Compiled By Prof. Vaibhav Vasani

member variables. Each property must contain at least one block of GET and SET. 2) Describe the use of command, connection and Data reader object to display content of Student table having fields Name, Roll No, avg and Grade. ANS: Imports System.Data.OleDb Public Class Form1 Dim cn As OleDbConnection Dim cmd As OleDbCommand Dim dr As OleDbDataReader Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click cn = New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=F:\miniproject\dummy.mdb;") cn.Open() cmd = New OleDbCommand("select * from demo", cn) dr = cmd.ExecuteReader Do While dr.Read TextBox1.Text = dr(0) TextBox2.Text = dr(1) TextBox3.Text = dr(2) TextBox4.Text = dr(3) End While Loop While dr.NextResult dr.Close() cn.Close() End Sub End Class

Compiled By Prof. Vaibhav Vasani

3) What is multi-threading? Explain the concept of multithreading with respect to vb.net. ANS: Multithreading is the feature provided by the operating system that enables your application to have more than one execution path at the same time. We may use multithreading to run different methods of our program at the same time. For example, Microsoft Word takes user input and displays it on the screen in one thread while it continues to check spelling and grammatical mistakes in the second thread and at the same time the third thread saves the document automatically at regular intervals. In a similar manner, WinAmp plays music in one thread, displays visualizations in the second and takes user input in the third. Multithreading is quite different from multitasking as here a single application is doing multiple tasks at the same time, while in multitasking different applications execute at the same time.

Imports System Module Module1 Public Sub Main() fun1() fun2() Console.WriteLine("End of Main()") Console.ReadLine() End Sub Public Sub fun1() Dim i As Integer For i = 1 To 5 Console.WriteLine("Fun1() writes:{0}", i) Next End Sub Public Sub fun2() Dim j As Integer For j = 10 To 6 Step -1 Console.WriteLine("Fun2() writes:{0}", j) Next

Compiled By Prof. Vaibhav Vasani

End Sub End Module

4) Describe how to convert VB application into VB.NET application with example. ANS: There are lots of difference in between VB6 and VB.NET and to help user upgrade VB6 projects into VB.NET, Microsoft created the visual basic Upgrade Wizard. This wizard is automatically opens whenever, user try to open a VB6 project in Vb.NET IDE. The upgrade wizard will convert the Visual Basic 6.0 application into the equivalent Visual Basic .NET application. The Visual Basic forms are converted into the equivalent Windows Forms. All the controls on the form are converted into their equivalent Windows controls. The upgrade wizard makes all the necessary syntax changes for converting the code into Visual Basic .NET. However, the upgrade wizard does not perform upgrades on Visual Basic 6.0 features such as DDE, OLE, DAO and RDO data bindings. The upgrade wizard produces an upgrade report. This report gives a status of the upgrade process, listing all the features that were upgraded by the wizard and all those features that were not upgraded. STEPS TO CONVERT VB6 PROGRAM INTO VB.NET: You can create a simple application in VB6 and run it in VB6 IDE Now, you try to open the application, made in VB6, in VB.NET IDE. A wizard will pop-up on the screen

Compiled By Prof. Vaibhav Vasani

If you want to proceed, click NEXT button. Now wizard will ask for the type (i.e. either a dll or exe) you want to upgrade into, your application. After selecting any one type click NEXT. Again you will be asked for the location where you want to store your upgraded application, provide the appropriate location and click NEXT. Then it will take 1-2 minutes to upgrade your application in VB.NET. And then finally you will get your project in solution explorer of VB.NET.

EXAMPLE: Code in VB6 Private Sub Form_Load() Dim a, b, c As Integer a=10 b=20 c=a+b Text1.Text = c End Sub The above VB6 code when upgrade to Vb.NET looks something like this: Option Strict Off Option Explicit On Friend Class Form1 Inherits System.Windows.Forms.Form Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs)Handles MyBase.Load Dim a, b As Object Dim c As Short UPGRADE_WARNING:. a=10 UPGRADE_WARNING:. b=20 UPGRADE_WARNING:. UPGRADE_WARNING:. c=a+b Text1.Text=CStr(c) End Sub End Class Q3 Attempt any 3

Compiled By Prof. Vaibhav Vasani

(a) What is Transaction and how transaction database is designed? Ans: A Transaction is an atomic unit of work that either fails or succeeds as a whole. In a transaction there can be many things to do, like update one thing, delete another, send email, response query and so on. If transaction is successful, all of these things will be done or executed as the case may be or if transaction fails then none of them will be executed. When a transaction is successful, it is said that this transaction has committed and all the tasks that it had to do will be done. If there is some error then the whole transaction will be brought back to its original state and none of task that it had to do will be completed, it is called rolling back of the transaction. Transactions are always executed as a whole. A transaction symbolizes code or a set of components or procedures which must be executed as a unit. All the methods must execute successfully or the complete unit fails. A transaction can be described to cover the ACID properties for mission critical appliances. 2. Write a code to bind the control to database consider student example 3. The book.mdb database file fields two tables. The book table and subject table the subject table has only two fields.write a VB project that wil display data in grid with the help of data table object 4. Create a web project using ASP.NET to display 10 pages on web document using content linker also describe content linking list file. Q4. Attempt any four: a. Describe CLR execution process with neat flowchart Ans. Windows (OS) is running at start Windows (OS) inspect the application to see whether it has a special header Which indicate that is a net application Checking for either a NET application or not If not, Windows continues to run the application.

Compiled By Prof. Vaibhav Vasani

If an application process is for NET, Windows will start the CLR and pass the application to CLR for execution. The CLR loads the executable assembly, finds the entry point and begins its execution To execute the code, the CLR must translate the IL to binary code that the operating system understands. This is the responsibility of the JIT compiler. The JIT compiler only compiles code before the first time that it executes. After the IL is compiled to machine code by the JIT compiler, the CLR holds the compiled code in a working set. The next time that the code must execute the CLR checks its working set & runs the code directly if it is already complied. This process of checking the working set, JIT compilation, assembly loading and execution continues until the program ends.

Start

Windows examines executable file header

Windows or CLR

windows Execute JIT compiled method No No End

Run CLR
Method already JITted?

Yes Execute method


More code to execute

Load Assembly Yes


Assembly in memory?

Yes

Compiled By Prof. Vaibhav Vasani

b. Describe steps to create SQL table using SQL server 1. Open enterprise manager of Microsoft SQL server 2. Select database and right click and select new database and a new dialog box appear on screen. Enter the name of database. E.g mydatabase 3. Explore mydatabase by clicking on + sign. Now right click on tables and select new table option 4. Enter columns, datatype and length of the columns and save the table 5. To enter some data into table select the table which you have created and right click select Open table->return all rows. c.Create a web page for entering new customer information. The field includes name, email, uname & password. Set the text mode property for two password field to password. Validate all field contain information. Display appropriate message for any empty field. Include Submit button. d.Write ASP.net form to display information of c drive using drive and folder object Ans. <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <script runat ="server" > Sub getinfo(ByVal sender As Object, ByVal e As System.EventArgs) Dim fs = Server.CreateObject("Scripting.filesystemobject") Dim d = fs.getdrive("c:") Dim f1 = fs.getfolder(d) Dim f2 Response.Write("<br/>Total size in bytes: " & d.totalsize) Response.Write("<br/>Available space in in bytes: " & d.availablespace) Response.Write("<br/>Free space in bytes: " & d.freespace)

Compiled By Prof. Vaibhav Vasani

Response.Write("<br/>The Response.Write("<br/>The Response.Write("<br/>The Response.Write("<br/>The

drive letter is: " & d.driveletter) drive type is: " & d.drivetype) file system is: " & d.filesystem) serial number is: " & d.serialnumber)

Response.Write("<br/>") Response.Write("<br/>") Response.Write("<br/>") Response.Write("<br/> The folders in drive are: ") For Each f2 In f1.subfolders Response.Write("<br/>" & f2.name) Next End Sub </script> <body> <form id="form1" runat="server"> <div> <asp:Button ID="Button1" OnClick ="getinfo" runat="server" Text="Show Detail About Drive" /></div> </form> </body> </html> e. What is postback? When does it occur? How you can keep a web application form recreating the list data when postback occur? ANS This property is used to check whether the page is being loaded and accessed for the first time or whether the page is loaded in response to the client postback. When an event is triggered, for instance, a button is clicked, or an item in a grid is selected, the page is submitted back to the server for processing, along with information about the event and any preexisting data on the page (via view state). We say the page posts back to the server. This is a powerful concept to grasp because it is postback that lets us run code on the server rather than on the clients browser, and it is postback that lets our server code know which items within a dropdown list were selected, or what information a user typed into a text box. But what would happen if you had multiple DropDownList controls that were populated with database data? Users could interact with those DropDownList controls and, in turn, we could set certain options within the page based on what they selected from the drop-down menus. Although this seems like a common task, with traditional ASP it incurred considerable overhead. The problem is that while the data thats bound to the drop-down menu from the database never changes, every time the user selects an item from the drop-down menu and a postback has to be Compiled By Prof. Vaibhav Vasani

done, the database must be accessed again to rebuild the contents of each drop-down list on the page. e.g Make 2 DropDownLists and Write in Default.aspx.vb Make AutoPostBack=true of 2 DropDownLists Partial Class _Default Inherits System.Web.UI.Page Dim fs = Server.CreateObject("Scripting.FileSystemObject") Dim fs1 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim f1 For Each f1 In fs.drives DropDownList1.Items.Add(f1.driveletter) Next End Sub Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged DropDownList2.Items.Clear() Dim loop1 As Integer Dim str As String For loop1 = 0 To DropDownList1.Items.Count - 1 If DropDownList1.Items(loop1).Selected Then str = DropDownList1.SelectedItem.ToString fs1 = fs.getfolder(str) End If Next Dim fd For Each fd In fs1.SubFolders DropDownList2.Items.Add(fd.name) Next End Sub End Class Compiled By Prof. Vaibhav Vasani

f. Describe Data table component of VB.Net. Describe VB.net and how all three components can be used to create data table ANS: The DataRow and DataColumn objects make up the DataTable . Using these objects' properties and methods, you can view, update, insert, and delete information from the tables. DataColumn representing the columns of data in a given table (which ultimately determine the kinds of data that can be entered into that table). . Each DataColumn object represents a column in a table. DataRow, representing the rows of data in a given table. This is the actual data within the table. DataView:- They are used to get a snapshot of the data in a table. Dataviews are much like read-only mini-datasets in which you can load only a subset of a dataset. EG: DESIGN TIME FORM Click here to create table DataGridView1

Imports System.Data.OleDb Imports System.Data Public Class q8 Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'DatabaseDataSet1.student' table. You can move, or remove it, as needed. 'Me.StudentTableAdapter.Fill(Me.DatabaseDataSet1.student) End Sub

Compiled By Prof. Vaibhav Vasani

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim table As New DataTable("table1") Dim col As New DataColumn Dim row As DataRow col = New DataColumn col.DataType = System.Type.GetType("System.Int32") col.ColumnName = "rollno" table.Columns.Add(col) col = New DataColumn col.DataType = System.Type.GetType("System.String") col.ColumnName = "Name" table.Columns.Add(col) Dim i As Integer For i = 0 To 4 row = table.NewRow row("rollno") = i row("Name") = "Record" & i table.Rows.Add(row) Next i DataGridView1.DataSource = table End Sub End Class

Q. 5. Attempt any three. a. Describe how to fill data set with data from multiple table. Ans. A single dataset can contain multiple tables . To create dataset that contain multiple tables by following steps: Import the namespaces that are necessary. Create the connection objects of the databases of tables that you want to fill into one dataset. Open the connections. Create the command objects . Create the dataAdapter objects which are the same as the number of tables one wat to fill to one dataset. Create dataset object. Fill the data set using fill method as follow :Compiled By Prof. Vaibhav Vasani

adap1.Fill(datasetobj, "tablename") fill all the tables using corresponding dataAdapter Object . Drag the datagridviews depending upon the number of tables. Set the datagridviews DataSource property to dataset.

Imports System.Data.OleDb Imports System.Data Public Class Form1 Dim Dim Dim Dim con, con1 As OleDbConnection com1, com2, com3 As OleDbCommand adap1, adap2, adap3 As OleDbDataAdapter dset As New DataSet

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click create the connection con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Book.mdb;") con1 = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\employee.mdb;") Open the connection con1.Open() con.Open() com1 = New OleDbCommand("Select * from Book1", con) com2 = New OleDbCommand("Select * from Subject", con) com3 = New OleDbCommand("Select * from emp", con1) adap1 = New OleDbDataAdapter(com1) adap2 = New OleDbDataAdapter(com2) adap3 = New OleDbDataAdapter(com3) adap1.Fill(dset, "Book1") adap2.Fill(dset, "Subject") adap3.Fill(dset, "emp") DataGridView1.DataSource = dset.Tables("Book1") Compiled By Prof. Vaibhav Vasani

DataGridView2.DataSource = dset.Tables("Subject") DataGridView3.DataSource = dset.Tables("emp") End Sub End Class OUTPUT:

2. Describe life cycle of asp page with post back Ans.

Stages Initializing Loading view stats

Description Server creates instance of server control View state of control posted by the client

Compiled By Prof. Vaibhav Vasani

Loading Loading Post back data

Pre-Rendering

Saving

Rendering Disposing Unloading

Is reloaded into new instance of control Instance of control is loaded on the page object which it is defined Server searches any data corresponding to the control that is loaded in the data posted by the client . Control is updated with the changes made to It. This prepares the control for rerendering During this phase changes in the state of control between the current request and the previous request Of the page is saved. Server creates corresponding html tag for the control All cleanup tasks such as closing files and database connections opened by control are performed All cleanup tasks such as destroying the instance of server control are performed. This is last stage in lifecycle of server control

3. Descibe built in asp.net object and their use. 4. What is cookie? Describe asp.net code to create & display cookies Q.6 Attempt any three of the foll: 1. Compare server side scripting and client side scripting 2. Create an advertisement for 4 companies using adrotator object 3. what is XML and describe creation of an XML file. 4. List and describe different arithmetic operator with example.

Compiled By Prof. Vaibhav Vasani

You might also like