what do you mean by · web viewq1. what do you mean by .net framework? ans. the .net framework is...

51
Vaishnoo Maa Computers[Cal-c] A Study Centre of PTU Subject:- Question Bank of Vb.Net Page No 1 of 51 Short Answer Questions Q1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability between the different languages of the .NET without making any change in codes. It has a common language runtime, system class libraries, compilers and other tools that are necessary to develop .NET applications. Q2. Define .net. Ans. . NET is a software framework that includes everything required for developing software for web services. It integrates presentation technologies, component technologies and data technologies on a single platform so as to enable users to develop internet application as easily as they do on desktop systems. Q3. Define Framework Class Library (FCL) Ans. The .Net Framework provides a huge Framework (or Base) Class Library (FCL) for common, usual tasks. FCL contains thousands of classes to provide access to Windows API and common functions like String Manipulation, Common Data Structures, IO, Streams, Threads, Security, Network Programming, Windows Programming, Web Programming, Data Access, etc. It is simply the largest standard library ever shipped with any development environment or programming language. The best part of this library is they follow extremely efficient OO design (design patterns) making their access and use very simple and predictable. You can use the classes in FCL in your program just as you would use any other class. You can even apply inheritance and polymorphism to these classes. Q4. What is the role of CLR in .NET.? Ans. The common language Runtime (CLR) is the foundation of all languages in visual studio .NET. CLR controls the code specified for the .NET platform. The CLR controlled code is called managed code. CLR removes the necessity of VB runtime layer out introduces MSIC(Microsoft Intermediate language. The code generated by MSIC is finally executed by CLR. Q5. Define common language specification (CLS)? Ans. Common language specification (CLS) can be defined as a set of rules designed to support inter operability these specific sets of rules apply only to items that are utilized by other programming languages. These rules also apply to the members such as methods properties, events, nested types and fields. Q6. Write short not on MSIL.

Upload: dangdan

Post on 14-Apr-2018

222 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 1 of 35

Short Answer QuestionsQ1. What do you mean by .NET framework?Ans. The .NET framework is as much the central nervous system of the .NET languages

provides interoperability between the different languages of the .NET without making any change in codes. It has a common language runtime, system class libraries, compilers and other tools that are necessary to develop .NET applications.

Q2. Define .net.Ans. . NET is a software framework that includes everything required for developing

software for web services. It integrates presentation technologies, component technologies and data technologies on a single platform so as to enable users to develop internet application as easily as they do on desktop systems.

Q3. Define Framework Class Library (FCL)

Ans. The .Net Framework provides a huge Framework (or Base) Class Library (FCL) for common, usual tasks. FCL contains thousands of classes to provide access to Windows API and common functions like String Manipulation, Common Data Structures, IO, Streams, Threads, Security, Network Programming, Windows Programming, Web Programming, Data Access, etc. It is simply the largest standard library ever shipped with any development environment or programming language. The best part of this library is they follow extremely efficient OO design (design patterns) making their access and use very simple and predictable. You can use the classes in FCL in your program just as you would use any other class. You can even apply inheritance and polymorphism to these classes.

Q4. What is the role of CLR in .NET.?Ans. The common language Runtime (CLR) is the foundation of all languages in visual

studio .NET. CLR controls the code specified for the .NET platform. The CLR controlled code is called managed code. CLR removes the necessity of VB runtime layer out introduces MSIC(Microsoft Intermediate language. The code generated by MSIC is finally executed by CLR.

Q5. Define common language specification (CLS)?Ans. Common language specification (CLS) can be defined as a set of rules designed to

support inter operability these specific sets of rules apply only to items that are utilized by other programming languages. These rules also apply to the members such as methods properties, events, nested types and fields.

Q6. Write short not on MSIL.Ans. MSIL (Microsoft Intermediate Language) is a CPU independent set of instructions.

When the source code is compiled to the managed code, the compiler decodes your source code into MSIL. Before the code can be executed, MSIL must be converted to the CPU-specific code by a Just-in-Time compiler (JIT).

Q7. What are Common Type System (CTS)

Ans. Net also defines a Common Type System (CTS). Like CLS, CTS is also a set of standards. CTS defines the basic data types that IL understands. Each .Net compliant language should map its data types to these standard data types. This makes it possible for the 2 languages to communicate with each other by passing/receiving parameters to/from each other. For example, CTS defines a type, Int32, an integral data type of 32 bits (4 bytes) which is mapped by C# through int and VB.Net through its Integer data type.

Q8. What do you mean by Garbage Collector (GC)

Ans. CLR also contains the Garbage Collector (GC), which runs in a low-priority thread and checks for un-referenced, dynamically allocated memory space. If it finds some data that is no longer referenced by any variable/reference, it re-claims it and returns

Page 2: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 2 of 35

it to the OS so it can be used by other programs as needed. The presence of a standard Garbage Collector frees the programmer from keeping track of dangling data. Ask any C++ programmer how big a relief it is!

Q9. Define Managed Code.Ans. An application program that is executed within a runtime engine installed in the same

machine. The application cannot run without it. The runtime environment provides the general library of software routines that the program uses and typically performs memory management. It may also provide just-in-time (JIT) conversion from source code to executable code or from an intermediate language to executable code. Java, Visual Basic and .NET's Common Language Runtime (CLR) are examples of runtime engines

Q10. What do You mean by Unmanaged Code.Ans. An executable program that runs by itself. Launched from the operating system, the

program calls upon and uses the software routines in the operating system, but does not require another software system to be used. Assembly language programs that have been assembled into machine language and C/C++ programs compiled into machine language for a particular platform are examples of unmanaged code.

Q11. Define Assembly.Ans. An assembly can beautiful defined as an assortment of resources that are constructed

to operate collectively for the generation of a unified set of functionalities. By encompassing all the requisite regulations, the assembly guarantee that cohesion. In other words it can beautiful termed as the unit of access to resources in the Common Language Runtime. In other words an assembly is technically a collections of files including binary resource files and executable modules implementing specific types, which the runtime considers as a atomic unit.

Q12. What is meaning of interoperability?Ans. Interoperability is a process provided by .NET so that any .COM component written in

any language is interoperable to any .NET language.Q13. What do you mean by Namespaces?Ans. One of the most important concepts in .NET framework is Namespaces. These help

in organizing object libraries and hierarchies simplifying object references prevent ambiguity when referring to objects and central scope of object identifiers. Namespaces are control to the .NET environment. Namespaces in VB.NET are declared using a block structure.

Q14. Define JIT compilation.Ans The MSIL must be converted by .NET framework . Just in time (JIT) compiler to the

nature code prior to its execution. This code is a CPU-specific code and run on the some computer architecture on which the JIT compiler is renewing.

Q15. Definition of COM.Ans. The component object Mode (COM) is a software architecture that utilizes binary

software components to construct applications. It facilitates the creation of application and systems with the help of components which are supplied by different software vendors. Com operates with the help of API (Application programming Interface) to facilitate creation of components for use in applications.

Q16. Define MetadataAns. Metadata describes the code by describing the types that the code defines and the

types that the code references externally. There is enough information stored in the metadata to (among other things): Manage code execution (load, execute, manage memory, and inspect execution state)

Install code, resolve implementation versions, and perform other administrative functions

Enable cross-language operation Q17. What are the Primary components of .Net framework.Ans. The primary componets of .Net Framework are

Common Language Runtime(CLR)Framework Base ClassesUser and Program interfaces(ASP .Net and Winforms)

Q18. How many Laguage .Net is supporting now.

Page 3: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 3 of 35

Ans. . Net is supporting 44 Languages commonly supported languages are COBOL,C++,VC++,JAVA etc.

The programm written in these languages are converted into .Net using the .Net frameworks intermidiate language that genrate managed code which is further converted into native code.

Q19. In Which Language Visual Basic .Net applications are complied before It can beautiful run.

Ans. In order to run Visual Basic .Net applications choose Visual Basic Developer from profile drop down box.

Q20. Differentiate between abstract and concrete classes.Ans. A class representing a base class which other types can subclass. A normal, non-

abstract class is called a concrete class. An abstract class may contain either or both abstract and concrete methods. (Properties cannot be marked abstract.) As in ordinary inheritance, a type derived from an abstract class inherits all the base type members including any method implementations. But, if any abstract methods are inherited, the class must either declare itself abstract or provide an implementation.

Q21. What is the difference between a namespace and assembly name.Ans. Namespace is the collection of classes and interfaces. Using namespace we can

group similar types of classes under a single group and other in the another group.Assembly is the name of the .Net project it may be of .DLL or .EXE based . Assembly is of three types1. public/shared 2. private 3.satelite

Q22. Features of OOPs.o Emphasis on data rather than procedure o Programs are divided into Objects o Data is hidden and cannot be accessed by external functions o Objects can communicate with each other through functions o New data and functions can be easily added whenever necessary o Follows bottom-up approach

Q23. What does the term data abstraction mean?Ans. Abstraction refers to act of representing essential features without including the

background details or explanation. There are two kinds of Abstraction

a. Data Abstractionb. Functional Abstraction

Q24. What is the basic purpose of programming language?Ans. The basic purpose of the programming language is to give instructions to a computer,

which then executes those instructions.Q25. Define Polymorphism

Ans. Polymorphism means the ability to take more than one form. An operation may exhibit different behaviors in different instances. The behavior depends on the data types used in the operation. Polymorphism is extensively used in implementing Inheritance.

Q26. Define Inheritance Ans. Inheritance is the process by which objects can acquire the properties of objects of

other class. In OOP, inheritance provides reusability, like, adding additional features to an existing class without modifying it. This is achieved by deriving a new class from the existing one. The new class will have combined features of both the classes.

Q27. What is are Classes Ans. A class is a collection of objects of similar type. Once a class is defined, any number

of objects can be created which belong to that class.

Page 4: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 4 of 35

Q28. Difference between Data Abstraction and Encapsulation

Ans. Abstraction refers to the act of representing essential features without including the background details or explanations. Classes use the concept of abstraction and are defined as a list of abstract attributes.

Storing data and functions in a single unit (class) is encapsulation. Data cannot be accessible to the outside world and only those functions which are stored in the class can access it.

Q29. What are the advantages of VB.net?Ans. Following are the advantages of VB.net.

a. OOP: - Object oriented programming structure. It is a true object oriented programs language.

b. Interpretabilities: - It provides the interpretabilities with the code developed in other languages supported by .net.

c. Event driven: - VB.net is event driven programming language. Using VB.net a user can create effective windows applications.

d. Interface: - VB.net has very rich development environment. Which provides user-friendly interface to the programmer.

e. Data types: - VB.net has huge no of data types to store any kind of data. More over all the data types used in VB.net are the objects.

Q30. Discuss option strict, option explicit and option compare.Ans. Option strict: - when this option is on , then you can not declare a variable without

specifying its data type i.e. when you need a variable you have to declare it with dim keyword and has to specify its data type also. By defaults this option is set to off.e.g.Dim name as stringOption compare: - Whenever you compare two strings in VB.net.e.g – HELLO with hello then it will result in that hello is great than HELLO. Because it is care sensitive while compare two strings. But when we want to make VB.net care sensitive then we use the option compare.There are two types of option compare statementsa. Option compare Binary (care sensitive) by defaultsb. Option compare Text (care insensitive)

Q31. Define GUI.Ans. GUI stands for Graphical User Interface. It makes windows applications prettier than

console applications. It makes windows applications easier to use. Instructions are given graphically and symbolically.

Q32. What is the difference between console application and window applications?Ans. Console applications execute on command line and they provide text user interface.

Window application executes on the windows environment and provide graphical user interface. Console applications don’t support event driven programming whereas windows applications support event driven programming.

Q33. What is the difference between property and method of an object?Ans. A property is an attribute of an object such as its color or size whereas a method is

something an object does such as change its position on the screen.Q34. What is the difference between new and initialize component method?Ans. The new method is where an instance of an object or a class is created. This

represents the constructor of the class. The initialize component method is where you assign values to properties of the newly created object.

Q35. Define IDE.Ans. IDE stands for integrated Development Environment. An environment to develop

windows based applications. It consists of solution explorer, properties window, toolbox, and form designer windows.

Page 5: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 5 of 35

Q36. What do you mean by option explicit ?Ans. In vb .NET we can declare variables by using option explicit and without option

explicit. If you use option explicit the compiler intend you to create the variable. If variable is used without declaration compiler will raise an error. If you option implicit variables are automatically declared when they are used in the program. To specify implicit declaration set option explicit to “OFF”.

Q37. Explain option strict.Ans. If you specify option strict to “ON” in your code then you have to specify the data type

with variable declaration. Option strict also restricts implicit narrowing type conversion between the data types. By default option strict is “OFF”.

Q38. What are the limitations to define the variable name in VB .NET?

Ans. 1. Can’t begin with any character other then a letter of the alphabet or an underscore.

2. Can’t contain embedded spaces.3. Can’t be longer then 255 characters.4. Can’t be same as the keyword such as private or public.5. Can’t have the same name as the name of another variable of the same

scope.Q39. Define Constant.Ans. A Constant is similar to a variable except that a constants value can’t change during

the life of the program. The main difference in syntax between declaring a variable and constant is that a constant must be initialized when it is declared.

Q40. Write down the name of operators used in VB.NET.Ans. Arithmetic operators

Assignment operatorComparison operatorLogical operator

Q41. What do you mean by type conversion ?Ans. A type conversion is the conversion of a value from one data type to another. Such

conversions are possible because many values can be stored by more then one data type.

Q42. How many Type of conversion supported by vb.NET?Ans:- In VB.NET there are two types of conversion.

1. Widening2. NarrowingWidening :- A widening Conversion is when a value is being converted to a data type with a larger number of bits. Such as integer to long. Widening conversion is performed implicitly.Narrowing :- A narrowing conversion is when a value is being converted to a data type with smaller number of bits. Such as long to integer. Narrowing conversion is performed implicitly only if option strict is ‘OFF’.

Q43. Differentiate between ‘/’ and ‘\’ operator?Ans :- The ‘/’ operator return the result in decimal place after dividing the first number with

second .The ‘\’ operator return the result of the division of two number in integer form.

Q44. Define input box?Ans:- The inputbox is an inbuilt form in vb.net. Use to insert value from the keyboard.

It has the following syntax:-Variablename=inputbox(prompt,title,default value)

Q45. What is the use option compare?Ans :- This option is use to specify the comparison mode to compare two strings. Option

compare may be one of the following but only one a time.Option compare binary :- By default this option is set. If this option is set then there is a difference between uppercase and lowercase of a letter in a string.Option compare text :- if this option is set then case sensitivity is ignore While comparing two strings.

Page 6: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 6 of 35

Q46. What is the used like operator?Ans :- Like operator is used to determine if a string matches a given pattern, returning true if

the string doesn’t match the pattern return false.Q47. :- Define AndAlso operator.Ans :- Andalso operator is almost identical to the and operator in comparing two Boolean

expression.. the only difference is that if the first expression is false ,the second expression is not evaluated.

Q48. Define OrElse operator.ANS :- The only difference between “orelse” and “or” operator is that if the first expression is

true, the second expression is not evaluated. Q49. Define iif statement used in vb .net.Ans :- iif statement is quite similar to an if .. then .. else statement. Executes first expression

if statement is true otherwise executes second expression. Syntax

Iif([expression],[return value if true],[return value if false])Q50. What are the conditional statements used in vb.net?Ans:- Following conditional statements are used

1. if then2. if then else3. if then elseif

Q51. What is the difference between checkbox and radiobutton?Ans :- We can select any number of options from list of checkboxes but only can select

single item from the list of radiobuttons.

Q52. What is the difference between select case statement?Ans :- The select case statement is quite similar to the if .. elseif statement. But they are not

the same. The Select case statement may evaluate only one expression, which then must be used for every comparison. Where in if then else statement more than one expressions are evaluated.

Q53. What is the difference between for .. next and for each statement?Ans :- For next :- this statement is used to perform operation on simple number or collection.

SyntaxFor var=initial to end stepvalueStatementNextFor each :- This statement is used to perform operation on collection or object of class.Syntax:For each var in collectionStatementNext

Q54. What is the difference between while.. end while and for nextAns :-

While end while For nextValue of the counter have to change Step statement is applied To run an indefinite number of times To run upto fixed number of timesQ55 . What is the difference between ByVal and ByRef ?Ans :- Passing an argument by value means the called procedure cannot modify the scalar

variable passed in the calling code as an argument.Passing by reference means the called procedure can modify the contents of a variable passed in the calling code as an argument.

Q56. What is the effect on Byval and Byref on the array variable?Ans: - The effect of byval and byref on array is slightly different then their effect on scalar

variables. If an array variable is passed by the Byval , the called procedure cannot change the array object to which the array variable points. If an array variable is passed by the byRef , the called procedure can change either the array object to which the variable points or the values of the individual member of the array.

Page 7: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 7 of 35

Q57. What you have to change in the parameter list while overloading procedure?Ans: - While overloading the procedure by naming them the same but change the argument

in at least one of the following respects?1. Number of arguments2. Order of the arguments3. Data types of the arguments.

Q58. What do you mean by modal and modeless dialog box?Ans :- Modal :- form the modal dialog boxes the application user cannot return to the main

form without closing to dialog box.Modeless :- the application user can return to the main form without having to close the dialog box.

Q59. What are the parameters used in Message Box ?Also explain their meaning?Ans: -

Parameter DescriptionText Thre prompt inside the message box to

convey a question or informationTitle Title of the message boxMessageBox.Buttons The buttons inside the message boxMessageBoxicon To specify the icon for message boxMessage box default button To specify the default selected button in the

message box

Q60. What is the difference between property procedure and event procedure?Ans : - 1. An event procedure is called by the occurrence of an event, usually generated by

an action of the application user. By contrast property procedure is called explicitly by code.2. the code inside an event procedure may take any action the programmer deems appropriate . By contrast, the code inside a property procedure has one of two specialized purposes, either to change or to return the value of a property.

Q61. How can you chage the size of Control.Ans. The size of a Control can be changed by changing the height and width propertiesof a

Control.Q62. Illustrate the use of Catch Statement.Ans. A catch block defined by the keyword catch “catches” the exception “thrown” by the

try block & handles it appropriately. The catch block is added immediately after the try block.The following example illustrates the use of simple try & catch statements.------------try {statement; // generates an exception}

catch (Exception e){statement; // processes the exception}

Q63. Which Statements are used to cast data imlicitly.Ans. Option strict is used to cast the data implicitly. By default option strict is “OFF”.

Q64. What are the use of OPTION EXPLICIT and OPTION BASE statemets.Ans. In vb .NET we can declare variables by using option explicit and without option

explicit. If you use option explicit the compiler intend you to create the variable. If variable is used without declaration compiler will raise an error. If you option implicit

Page 8: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 8 of 35

variables are automatically declared when they are used in the program. To specify implicit declaration set option explicit to “OFF”.Option Base is supported in Visual Basic 6.0 using this statement we can initialize the base array element to 1 instead of 0. but in Visual Basic .Net option Base Statement is not Supported so we Can not initialize directly the base element of array to 1

Q65. Differetiate between variant and object data types.Ans. Variables declared as Variant can store any type of value. Depend upon the value

initialize the data type of variable is defined and it only used with value type data. Wheras object is the base type for all the type used in .Net whether it is value or referenced type.

Q66. What are the changes made to Dim statement from VB6 to VB .Net.Ans. Dim statement is used to declare variable in Visual Basic .Net and VB6. There is no

change in the declaration of Variable.

Q67:- What is the difference between structured and unstructured Exception HandlingAns : - Visual basic .net support two ways to handle exceptions, structured and unstructured

Unstructured exception handling is a carryover from prior versions of the visual basic. Structured exception handling is anew to visual basic in visual basic. Net, and is consistent with how exception are handled in other languages such as c++.

Q68:- Define Exception classes used by VB.NET to handle exceptions.Ans ::- On the top of all exception classes in VB.NET is the Exception class. All the classes

are the sub class of the exception class. There are number of sub classes .

1. InvalidCastException class represents the exception that is thrown for invalid attempts to texplicitly convert an expression from the one data type to another.

2. DivideByZeroException : - This class represents the exception that is thrown when there is an attempt to divide an integral or decimal value by zero.

Q69:- What are the different ways to place break mode ?Ans : - . At the start of the program , using the debug ->step into or debug | start over menu

command.At a predetermined place in the program , using a breakpoint or run to cursor.While the program is running , using the menu command debug | break all.

Q70- What is break mode?Ans :- Break mode is the process to slow down the program process so that any logic error

can easily found. You can suspend the execution of your program by placing your program in break mode . entering break mode does not end the execution of your program; execution of the program when an exception occurs.

Q71:- What is the difference between structured exception handling and data validation?

Ans :- Data validation, as its constituent words indicate, concerns whether data is valid, particularly data being input by the application user. For example , if test scores were being entered into an application, data validation would be used to ensure that each score entered was 0 and 100 . Input below 0 and 100 would not create an exception . Rather , input below 0 or above 100 simply would be incorrect data. Thus data validation is used to prevent invalid data, not exception.

Q72: - Define Button Control and its class.Ans : - The Button class represents a button control, which is one of the most commonly

used controls in Windows the default event for button class is The Button class's Click event, which it inherits from Control, is its most commonly used.

Q73: - What do you mean by combobox also define the classes used by combobox control?Ans: - Both the ComboBox and ListBox classes derive from the ListControl class; therefore,

the ComboBox class is very similar to the ListBox class and has properties and methods similar to those of the ListBox class.The following properties are specific to the ComboBox class:DropDownStyle : Defines the drop-down style of the ComboBox. It can take any value of the ComboBoxStyleenumeration: DropDown (the default value),

Page 9: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 9 of 35

DropDownList, and Simple.

Q74:- Why the group box control is used?Ans :- , a GroupBox control is used for grouping other controls, such as radio buttons orcheckboxes; it corresponds to the Frame control in Visual Basic 6.0.Q75:- What do you mean by link label control?Ans :- This is the new control introduce in vb.net. The LinkLabel class represents a label

that can function as a hyperlink, which is a URL to a web site.Its two most important properties are Text and Links. The Text property is a String that defines thelabel of the LinkLabel object. You can specify that some or all of the Text property value is a hyperlink

Q76. How can you convert a standard text box into a password box?Ans. To convert a standard text box set the password char property from the properties

window or you can set it run time also: e.g.Textbox1. password char = ‘*’ (Run time) or till the ‘*’ is the password char property of that textbox in design view.

Q77. How items can be added into a combo box?Ans. To add the items in combo box the add methods is used. Use the following syntax to

add items in a Combo box.e.g.

Combobox1. Items. Add (“Hello”)

Q78. Explain the use of “load Picture” property in image controls.Ans. The load picture property of image control is used to assign a picture to image control

e.g..Image1.picture = load picture (“c:\window\clouds.jkg”)

Q79. What is the purpose of private and public keywords?Ans. There both private and public keywords are use to define the scope of variables and

methods.

*Public: - This keyword means that this property procedure and variables can be accessed throughout the application, then by code indifferent form.

*Private: - The private keyword defines the scope of the variable and procedures with in a module in which they are defined.

Q80. What are the splash screens? When they should be added?Ans. Splash screens are the pre-designed forms. These splash screens are used to

display the software name, version, company name etc. This screen is the first screen of the project.

Q81. How can you debug and measure performance in VB.net?Ans. You can debug your program by stepping through your program on line at a time or

by running your code to a specific paint and then stopping. If you want to start debugging from the beginning of your program, you may choose step into or step over from the debug menu.

Q82. What are the anchoring and docking properties of terms?Ans. The anchor property forces one or more of your controls borders to remains at 0.

Constant distance from the form’s border.The dock property is also important. A is similar to the align property. It forces

the particular control to stick to a side of the form. Or cover the whole firm, using the fill option.

Q83. Differentiate early binding and late binding.Ans. In early binding methods are attached to class at Compilation time. And in the late

binding methods are attached to the class at run time.Late binding also provide dynamic method dispatching

Q84. List the type of objects available in VB.NET.Ans. Following projects are provided by VB.NET in their project templates.

Window application

Page 10: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 10 of 35

Class library Window control library Web application Web service Web control library.

Q85. Define the use of date time picker.Ans. VB.NET includes it own date/time control called the date/time picker, which can be

found in the win forms group in the toolbox . When placed on a form it looks like control box and contains a date but actually when the drop down arrow is pressed.

Q86. What is The Module Keyword

Ans. A VB.Net program may contain one or more modules. The Main() sub-procedure usually resides in one of these modules. Modules in VB.Net are a combination of general data (fields) and general functions (methods) that are accessible to any code that can access the namespace of a module. All the members (fields, methods, properties) defined inside a module are shared by default.

Q87. What are CommentsAns. Comments are created by programmers who wish to explain the code. Comments are

ignored by the compiler and are not included in the executable code. VB.Net uses similar syntax for comments as used in VB and assembly language. The text following a single quotation mark (' any comment) is a line comment. the ending is the end of the line.

Q88. Define Sub ProcedureAns. A sub procedure is a method that does not return any values. A sub procedure in

VB.Net is defined using the Sub keyword. A sub procedure may or may not accept parameters. A method that does not take any parameters is called a parameterless method.

Q89. What are Constructors

Ans. Constructors are a special kind of sub procedure. A Constructor has the following properties

It always has the name 'New' Being a sub procedure, it does not return any value It is automatically called when a new instance or object of a class is created, hence

called a constructor.

Q90. Discuss Finalize() Method of Object class

Ans. Each class in VB.Net is automatically (implicitly) inherited from the Object class which contains the method Finalize(). This method is guaranteed to be called when your object is garbage collected (removed from memory). You can override this method and put here the code for freeing resources that you reserved when using the object.

Q91. What is List Box Control

Ans. A list box control contains a list of items which can be selected by the user. A list box can be set to allow the user to select one or more items. In .NET the list box is represented by the System.Windows.Forms.ListBox class. Each list box instance contains a collection called 'Items' that holds the items present in the list. An item (usually a string) can be added or removed from the list box.

Q92. Define Combo Box Control

Ans. The combo box is similar to the list box in that it is used to display a list of items. The combo box is presented in .NET through the System.Windows.Forms.ComboBox class. The combo box has three visual designs which can be toggled using the

Page 11: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 11 of 35

ComboBox class' 'DropDownStyle' property. The three designs are named 'Simple', 'DropDown' and 'DropDownList'.

Q93. How can you create a form with no maximize and/or minimize button?

Ans. The base class System.Windows.Forms.Form has two Boolean properties; MaximizeBox and MinimizeBox. A form with no maximize and/or minimize box can be created by setting these two properties to False.

Q94. Discuss the use of Toolbar in Visual Basic .Net.

Ans. The Toolbar is also added like other resources (menu, image list, etc). It is represented in .NET by the System.Windows.Forms.ToolBar class. The ToolBar class contains a collection called Buttons which can be used to add/remove items from the toolbar. An Image List can also be attached to the toolbar. When you click the Buttons property in the properties window, Visual Studio presents you the familiar interface to add and remove buttons. Event handlers can be added for the toolbar just by double clicking the button in the designer.

Q95. What do you mean by Operator PrecedenceAns. All operators are not treated equally. There is a concept of operator precedence in VB.Net as in

Dim i As Integer = 2 + 3 * 6 ' i would be 20 not 30

3 will be multiplied by 6 first then the result will be added to 2. This is because the multiplication operator * has precedence over the addition operator +. For a complete table of operator precedence, consult msdn or the .net framework documentation.

Q96. What are Parameters and How to Pass Parameters to Functions.

Ans. A parameter is an argument that is passed to the method by the method that calls it. Parameters are enclosed in parentheses after the method name in the method declaration. You must specify types for these parameters. The general form of a method with parameters looks like this:

Public Function Add(ByVal x1 as Integer, ByVal y1 as Integer)------------Implementation------------End Function

Q97. How to Call a Method.

Ans. Calling Methods

A method is not executed until it is called. A method is called by referencing it's name along with any required parameters. For example, the above code called the Add method in Sub main like this:Write("Sum is" & " " & Add()).

Page 12: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 12 of 35

Long Answer Questions

Q1. Discuss the Concepts of OOP: o Objects o Classes o Data Abstraction and Encapsulation o Inheritance o Polymorphism

Briefly on Concepts:

Objects

Objects are the basic run-time entities in an object-oriented system. Programming problem is analyzed in terms of objects and nature of communication between them. When a program is executed, objects interact with each other by sending messages. Different objects can also interact with each other without knowing the details of their data or code.

Classes

A class is a collection of objects of similar type. Once a class is defined, any number of objects can be created which belong to that class.

Data Abstraction and Encapsulation

Abstraction refers to the act of representing essential features without including the background details or explanations. Classes use the concept of abstraction and are defined as a list of abstract attributes.

Storing data and functions in a single unit (class) is encapsulation. Data cannot be accessible to the outside world and only those functions which are stored in the class can access it.

Inheritance

Inheritance is the process by which objects can acquire the properties of objects of other class. In OOP, inheritance provides reusability, like, adding additional features to an existing class without modifying it. This is achieved by deriving a new class from the existing one. The new class will have combined features of both the classes.

Polymorphism

Polymorphism means the ability to take more than one form. An operation may exhibit different behaviors in different instances. The behavior depends on the data types used in the operation. Polymorphism is extensively used in implementing Inheritance.

Q28. Define Com, Dcom in detail: -Ans. Com: - The component object Model (COM) is a software architecture that utilizes

binary software components to construct applications. It facilitates the creation of applications and systems with the help of components, which are supplied by different software vendors.

Page 13: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Languages

Common language specification

Web server User Interface

Data and XML

Class libraries

Common language, Runtime

Visual studio .NET

Specifications layers

Services layer

Data layer

Depending layer

Base layer

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 13 of 35

COM operates with the help of application programmes interface (API) to facilitate creation of components for use in applications. This interface also allows diverse components to interact with each other. Now before their components are actually deemed worthy of bans chosen they must conform to a binary structure, which is specified by Microsoft. It is important to note that COM is a general architecture for component software. This enables all types of users to employ the components easily.

Q2. Explain .NET architecture in depth.Ans. To really understand the issuance of .NET,

start identifying the products of Microsoft with relation to .NET. In other words all he forth coming version of desktop and serves software from Microsoft will new come with an appendage of .NET. This would describe the .NET classification as follows:The complete set of services and applications can now access the set of common services in .NET from object-based languages. The services which are common will be identified separately because they will relate themselves to the inter mediate code for execution. Standing out of the behavior of architecture explained above but still being the part of the same. It’s something like this.The services operate in a common language Runtime which means that it is a part of .NET framework, but with a different approach.

Q3. Advantages of .NET for end user.Ans. The advantages to the developer of the common language Runtime configuration

system include.

Storage of rich data types: - The settings used to configure the runtime do not all have the same size and shape. Some of the data is static and can readily be represented as a relational schema; same of the data is stored as serialized objects. The configuration system supports the storage of there various types of data.

Flexibility: - The runtime developer can add configuration through a central authority, additionally end uses customers can leverage the configuration systems for customer specific settings.

Hierarchical configuration: - It is often useful for administrators to specify configuration information at various levels of a hierarchy these levels include the machine the user system supports the ability to specify configuration at multiple custom defined levels and provides for custom merge rules to be supplied.

Integration with admin tools: - The interface defined by the configuration system support both read and write access and can be efficiently used by administrates tools.

Q4. Define assemble in detail.

Common services MSIL Common language Runtime

Page 14: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 14 of 35

Ans. Assembly: One or more modules that constitute a unit of deployment can be defined as an assembly. Each assembly holds a list of component metadata called a manifest. Science the manifest holds critical method about security type visibility and component versioning the abstraction of the assembly assumes significance. It is imperative that every managed type exists within the scope of an assembly. In VB.NET a solitary assembly typically represents each project you create your project must include a reference to this other assembly, whenever you need to utilize he managed types in your project from another assembly.During the creation of an assembly you must determine the managed types that must be visible from outside the assemble the public and private keywords facilitated exhibitions or hiding of a class or interface type.

Q5. Define security of .NET applications.Ans. The security of .net applications encompasses the following key concepts.

Permission: The common language Runtime (CLR) enables the code to executes process only those operations are enforced which are approved by the code. In other words, if the code gives permissions to certain specific operations, only those operations are implement.

Type-safe code: the type –safe code accesses only the authorized memory location, it can read values from private fields of another object. It can access types only in a well-defined and stipulated manner. It plays major role in assembly isolation and security enforcement. Type safe code enables the runtime to completely isolate assemblies from each other. It increase application reliabilities.

Code access security: Code access security mechanism in the .net framework. It facilitates protection of computer system form malicious mobile code. It also enables mobile code to run safely.

Role-based security: The .net framework role-based security offers authorization support that is flexible and extensible enough to meet the needs of a wide spectrum of applications. A role denotes a named set of users that passes the same privileges with respect to security.

Q6. Define MSIL (Microsoft Intermediate Language) Code in Detail:

Ans. When we compile our .Net Program using any .Net compliant language (like C#, VB.Net, C++.Net) it does not get converted into the executable binary code but to an intermediate code, called MSIL or IL, understandable by CLR. MSIL is OS and hardware independent code. When the program needs to be executed, this MSIL, or intermediate code, is converted to binary executable code (native code). The presence of IL makes possible the Cross Language Relationship as all the .Net compliant languages produce similar, standard IL code.

Q7. What are the Advantages of OOP

Ans. Object-Oriented Programming has the following advantages over conventional approaches:

o OOP provides a clear modular structure for programs which makes it good for defining abstract data types where implementation details are hidden and the unit has a clearly defined interface.

o OOP makes it easy to maintain and modify existing code as new objects can be created with small differences to existing ones.

Page 15: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 15 of 35

o OOP provides a good framework for code libraries where supplied software components can be easily adapted and modified by the programmer. This is particularly useful for developing graphical user interfaces

Q8. Define Entities of .Net Application

Ans. There are three types Entities of .Net Application which are

Modules

A VB.Net program may contain one or more modules. The Main() sub-procedure usually resides in one of these modules. Modules in VB.Net are a combination of general data (fields) and general functions (methods) that are accessible to any code that can access the namespace of a module. All the members (fields, methods, properties) defined inside a module are shared by default.

Assemblies

An assembly can beautiful defined as an assortment of resources that are constructed to operate collectively for the generation of a unified set of functionalities. By encompassing all the requisite regulations, the assembly guarantee that cohesion. In other words it can beautiful termed as the unit of access to resources in the Common Language Runtime. In other words an assembly is technically a collections of files including binary resource files and executable modules implementing specific types, which the runtime considers as a atomic unit.

Type

A class is a collection of objects of similar type. Once a class is defined, any number of objects can be created which belong to that class.

Q9. Discuss the role of MSIL and Metadata in .Net.

Ans. When we compile our .Net Program using any .Net compliant language (like C#, VB.Net, C++.Net) it does not get converted into the executable binary code but to an intermediate code, called MSIL or IL, understandable by CLR. MSIL is OS and hardware independent code. When the program needs to be executed, this MSIL, or intermediate code, is converted to binary executable code (native code). The presence of IL makes possible the Cross Language Relationship as all the .Net compliant languages produce similar, standard IL code.

Metadata describes the code by describing the types that the code defines and the types that the code references externally. There is enough information stored in the metadata to (among other things): 1. Manage code execution (load, execute, manage memory, and inspect execution

state) 2. Install code, resolve implementation versions, and perform other administrative

functions 3. Enable cross-language operation

Page 16: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 16 of 35

Q10. Discuss .Net Base class Libraries.Ans. .Net supplies a library of base classes that we can use to implement applications quickly.

We can use them by simply instantiating them and invoking their methods or by inheriting them through derived classes, thus extending their functionality.Much of the functionality in the base framework classes reside in the vast namespace called system. We can use the base classes in the system namespace for many different tasks

including 1. Input/Output operations2. String Handling3. Managing arrays, lists, maps etc.4. Accessing files and file system.5. Accessing the registry6. Security7. Windowing8. Window messages9. Database management10. Evaluation of mathematical functions11. Drawing12. Managing errors and exception13. Connecting to the Internet

Q11. What are different components of CLR?. Discuss their uses.Ans. The components of CLR are as follows:

Common language specification (CLS) can be defined as a set of rules designed to support inter operability these specific sets of rules apply only to items that are utilized by other programming languages. These rules also apply to the members such as methods properties, events, nested types and fields.

MSIL (Microsoft Intermediate Language) is a CPU independent set of instructions. When the source code is compiled to the managed code, the compiler decodes your source code into MSIL. Before the code can be executed, MSIL must be converted to the CPU-specific code by a Just-in-Time compiler (JIT).

Common Type System (CTS)

Net also defines a Common Type System (CTS). Like CLS, CTS is also a set of standards. CTS defines the basic data types that IL understands. Each .Net compliant language should map its data types to these standard data types. This makes it possible for the 2 languages to communicate with each other by passing/receiving parameters to/from each other. For example, CTS defines a type, Int32, an integral data type of 32 bits (4 bytes) which is mapped by C# through int and VB.Net through its Integer data type.

Garbage Collector (GC)

CLR also contains the Garbage Collector (GC), which runs in a low-priority thread and checks for un-referenced, dynamically allocated memory space. If it finds some data that is no longer referenced by any variable/reference, it re-claims it and returns it to the OS so it can be used by other programs as needed. The presence of a standard Garbage Collector frees the programmer from keeping track of dangling data. Ask any C++ programmer how big a relief it is!

Managed Code.An application program that is executed within a runtime engine installed in the same machine. The application cannot run without it. The runtime environment provides the general library of software routines that the program uses and typically performs memory management. It may also provide just-in-time (JIT) conversion from source

Page 17: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 17 of 35

code to executable code or from an intermediate language to executable code. Java, Visual Basic and .NET's Common Language Runtime (CLR) are examples of runtime engines

JIT(Just in Time)The MSIL must be converted by .NET framework . Just in time (JIT) compiler to the

nature code prior to its execution. This code is a CPU-specific code and run on the some

computer architecture on which the JIT compiler is renewing.

Base Class Library

The .Net Framework provides a huge Framework (or Base) Class Library (FCL) for common, usual tasks. FCL contains thousands of classes to provide access to Windows API and common functions like String Manipulation, Common Data Structures, IO, Streams, Threads, Security, Network Programming, Windows Programming, Web Programming, Data Access, etc. It is simply the largest standard library ever shipped with any development environment or programming language. The best part of this library is they follow extremely efficient OO design (design patterns) making their access and use very simple and predictable. You can use the classes in FCL in your program just as you would use any other class. You can even apply inheritance and polymorphism to these classes.

Q12. What is a Constructor and explain their use with the help of example.

Ans. Constructors are a special kind of sub procedure. A Constructor has the following properties

It always has the name 'New' Being a sub procedure, it does not return any value It is automatically called when a new instance or object of a class is created,

hence called a constructor.

The constructor contains initialization code for each object like assigning default values to fields. Let us see some examples

Imports System

Class Person' fieldPrivate mName As String

' constructorPublic Sub New()mNname = "unknown"Console.WriteLine("Constructor called...")

End Sub

'propertyPublic Property Name As StringGetReturn mNameEnd Get

Set(ByVal Value As String)

Page 18: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 18 of 35

mName = ValueEnd Set

End PropertyEnd Class

In the Person class above, we have a private field mName, a public constructor which initializes the mName field with string value "unknown" and prints that when it is called. Then we have a public property to read/write private field mName. Lets make a module Test which contains the Main() method and which uses the Person class

Module TestPublic Sub Main()Dim thePerson As new Person()Console.WriteLine("The name of person in object thePerson is " & thePerson.Name)thePerson.Name = "Faraz"Console.WriteLine("The name of person in object thePerson is " & thePerson.Name)End SubEnd Module

In our Test module, we made an object of the Person class and printed the name of the person. We then changed the value of the Name and printed the Name again. The result of the program is so

Constructor called…

The name of person in object thePerson is unknownThe name of person in object thePerson is Faraz

Note that the constructor is called just as we created a new instance of Person class and initialized the field name with the string "unknown".

Q13 What do you mean by namespaces for what it is used in .net.Or

What is a Namespace? How do we access a namespace Programmatically.Ans. One of the most important concepts in .net framework is namespaces. These help in

organizing object libraries and hierarchies, simplifying object references prevent ambiguits when referring to objects and control scope of object identifies. Namespaces are control to the .NET environment, as they provide a mechanism by which classes can be organized into logical grouping making them easier to find and manage. Namespaces is VB.NET are declared using a block structure Namespaces the Namespace

Public class the classEnd classEnd Namespace.

Any classes, structures or other types declared within the Namespaces.............End Namespace block will be addressed using that namespaces. In this example our class is referenced using the namespace, so declaring a variable would be done as follow.

Private objects as the namespace. The classAs namespaces are treated using a block structure , it is possible for a single

source file to not only contain many classes, but also many Namespaces.

Q14. Difference between Toolbox, Properties and Class View Tabs

Now there is a single toolbox for all the Visual Studio.Net's languages and tools. The toolbox (usually present on the left hand side) contains a number of common controls

Page 19: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 19 of 35

for windows, web and data applications like the text box, check box, tree view, list box, menus, file open dialog, etc.

The Properties Tab (usually present on the right hand side in the IDE) allows you to set the properties on controls and forms without getting into code.

The Class View Tab shows all the classes that your project contains along with the methods and fields in tree hierarchy. This is similar to VC++ 6's class view.

Q15. Define 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.

Q16. What are events. How you change the properties of events.

Ans. Events are certain actions that happen during the execution of a program that the application wishes to be notified about, so it can respond. An event can be a mouse

Page 20: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 20 of 35

click, a keystroke or an exact time (alarm). An event is basically a message which is said to be fired or triggered when a respective action occurs. A class that raises an event is called 'an event sender', a class that receives an event is called 'an event consumer' and the method which is used to handle a particular event is called 'an event handler'. The properties of an event can be changed by argument passed in the event procedure. E.g if you are handling button click event or text change event there is no need to pass any parameter but if you are using Mousemove event with any control we have to specify the X and Y Location by using X and Y variables of Eventargs class. If you want to use the button of the mouse for left click and right click the button attribute must also be specified by as an argument with event procedure.

Q17. Explain the procedure of adding control to the form.

Ans. The form is a control. It has a specialized purpose, which is to contain other controls. However its functionality is limited to this purpose. The form does not permit typing of text, listing data, selection of choices or may others tasks that an application may need to perform. You need other controls for that additional functionality. For example:

Select the Label control from the toolbox and place it on the form. Resize it as appropriate. Select (click) the label on the form, and in the properties window set its Text property to "Hello WinForm" and the Name property to 'lblGreeting'. The name of a control is the name of its corresponding instance in the source code. Select the Button control from the toolbox, place it on the form and resize it appropriately. Select (click) the button and set its Name property to 'btnExit' and its Text property to 'Exit' using the properties window. The form should now look like this:

Q18. What are the advantages of VB.net?Ans. Following are the advantages of VB.net.

OOP: - Object oriented programmes structure. It is a true object oriented programs language.

Interpretabilities: - It provides the interpretabilities with the code developed in other languages supported by .net.

Event driven: - VB.net is event driven programmes language. Using VB.net a user can create effective windows applications.

Interface: - VB.net has very rich development environment. Which provides user-friendly interface to the programmer.

Page 21: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 21 of 35

Datatypes: - VB.net has huge no of data types to store any kind of data. More over all the data types used in VB.net are the objects.

Q19. Difference Between Project and Solutions

A Project is a combination of executable and library files that make an application or module. A project's information is usually placed in a file with the extention '.vbproj' where 'vb' represents Visual Basic. Similarly, C#.Net projects are stored as '.csproj' files. There are several different kinds of projects such as Console Applications, Windows Applications, ASP.Net Web Applications, Class Libraries and more.

A solution on the other hand is a placeholder for different logically related projects that make some application. For example, a solution may consist of an ASP.Net Web Application project and a Windows Form project. The information for a solution is stored in '.sln' files and can be managed using Visual Studio.Net's Solution Explorer. Solutions are similar to VB 6's Project Group and VC++ 6's workspace.

Q20. What are the hardware and software requirements for visual basic .NET.Ans. HARDWARE:-

Processor:- Pentium II with 450 Mhz.RAM:- 128 MBHard Disk Space :- 3 GBVideo:- 800 X 600 , 256 Colors.SOFTWARE:-Operating System:- Higher then windows 98Application Software:- .NET framework, IE-6.0, Service pack 2 (windows)

Q21. Define data types used in VB .NET.Ans. Visual basic has a number of predefined data types.

Types Bytes RangeBoolean 2 True or FalseByte 1 0 to 255Char 2 0 to 65535Date 8 Jan 1, 0001 to Dec

31,9999Decimal 12Double 8Integer 4 -2,147483,648 to 2,1,47

483,647Long 8Object 4Short 2Single 4String 10 bytes +2 bytes for every

character in the string

Q22. Define the Scope of Variable.

Ans. The  scope of an element in code is all the code that can refer to it without qualifying it's name. Stated other way, an element's scope is it's accessibility in code. Scope is normally used when writing large programs as large programs divide code into different classes, modules, etc. Also, scope prevents the chance of code referring to the wrong item. The different kinds of scope available in VB .NET are as follows:

Block Scope: The element declared is available only within the code block in which it is declared.

Page 22: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 22 of 35

Procedure Scope: The element declared is available only within the procedure in which it is declared.

Module Scope: The element is available to all code within the module and class in which it is declared.

Namespace Scope: The element declared is available to all code in the namespace.

Q23. What are Option Statements. Discuss in detail.

Ans. The Option statement is used to set a number of options for the code to prevent syntax and logical errors. This statement is normally the first line of the code. The Option values in Visual Basic are as follows.

Option Compare: You can set it's value to Text or Binary. This specifies if the strings are compared using binary or text comparison operators.Option Explicit: Default is On. You can set it to Off as well. This requires to declare all the variables before they are used.Option Strict: Default is Off. You can set it to On as well. Used normally when working with conversions in code. If you want to assign a value of one type to another then you should set it to On and use the conversion functions else Visual Basic will consider that as an error.

Example of Option Statement

The following code demonstrates where to place the Option statement.

Option Strict OffImports SystemModule Module 1

Sub Main ()Console.WriteLine (“Using Option”)End Sub

End Module

The following code throws an error because Option Strict is On and the code attempts to convert a value of type double to integer.

Option Strict OnImports System.ConsoleModule Module2

Sub Main()Dim i As IntegerDim d As Double = 20.12i = dWriteLine(i)End Sub

End Module

We always should program with Option Strict On. Doing so allows us to catch many errors at compile time that would otherwise be difficult to track at run time.

Q24. What are Variables .How we declare variables discuss with example.

Page 23: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 23 of 35

Ans. Variables are used to store data. A variable has a name to which we refer and the data type, the type of data the variable holds. VB .NET now needs variables to be declared before using them. Variables are declared with the Dim keyword. Dim stands for Dimension.

Example

Imports System.ConsoleModule Module1Sub Main()Dim a,b,c as Integer'declaring three variables of type integera=10b=20c=a+bWrite("Sum of a and b is" & c)End SubEnd Module

Q25. What are Statements .

Ans. A statement is a complete instruction. It can contain keywords, operators, variables, literals, expressions and constants. Each statement in Visual Basic should be either a declaration statement or a executable statement. A declaration statement is a statement that can create a variable, constant, data type. They are the one's we generally use to declare our variables. On the other hand, executable statements are the statements that perform an action. They execute a series of statements. They can execute a function, method, loop, etc.

Q26. What are Access Specifiers in visual Basic .Net.

Ans. Access specifiers let's us specify how a variable, method or a class can be used. The following are the most commonly used one's:

Public: Gives variable public access which means that there is no restriction on their accessibilityPrivate: Gives variable private access which means that they are accessible only within their declaration contentProtected: Protected access gives a variable accessibility within their own class or a class derived from that classFriend: Gives variable friend access which means that they are accessible within the program that contains their declarationProtected Friend: Gives a variable both protected and friend accessStatic: Makes a variable static which means that the variable will hold the value even the procedure in which they are declared endsShared: Declares a variable that can be shared across many instances and which is not associated with a specific instance of a class or structureReadOnly: Makes a variable only to be read and cannot be written

Q27. Write the name of type conversion keywords.Ans :- following keywords are used to perform narrowing conversion.

Type conversion keyword Convert an expression to data type Allowable data types of expression to be converted

Cbool Boolean Any numeric, string and object type

Cbyte Byte Any numeric, string,object and

Page 24: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 24 of 35

BooleanCchar Char String and objectCdate Date String and objectCdbl Double Numeric, Boolean,

string and object Cdec Decimal Numeric, Boolean,

string, objectCint Integer Numeric, Boolean,

string and objectClng Long Numeric, Boolean,

string, and objectCobj Object Any typeCshort Short Numeric, Boolean,

string , objectCsng Single Numeric,

Boolean ,string , object

Cstr String Numeric, Boolean, string, object

Ctype Type specified following the comma

When converting to an elementary type the same type as allowed for the corresponding conversion keyword.

Q28 :- What do you mean by precedence of operator?Ans :- precedence of operator specify the execution process in a particular statement. It is

necessary to determine which is the correct answer to the statement.Arithmetic operators have the following precedence Priority Operators Description1 ^ Exponent2 - Unary negation operator3 *, / Multipication and floating point division 4 \ Integer division5 Mod Modulus(remainder)6 +,- Addition and subtraction, string

concatenation7 & String concatenation( &)

Q29:_ List different parameters to used in format function to specify the formatAns :-

Format name DescriptionGeneral Number, G or g Displays number with no thousand separatorCurrency , C or c Displays number with thousand separator, if

appropriate; displays two digits to the right of the decimal separator, output is based on system locale settings.

Fixed, F, or f Displays at least one digit to the left and two digits to the right of the decimal separator

Standard , N or n Displays number multiplied by 100 with a percent sign(%) appended to the right.

Scientific, E or e Uses standard scientific notationD or d Displays number as a string that contains the value of

the number in decimal format.X or x Displays number as a string that contains the value of

the number in hexadecimal format.

Q30 :- List array functions and properties ?

Page 25: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 25 of 35

Ans :- The Array object , like other objects, has properties and methods. There are following method and properties.

Clear Sets a range of elements in an array to default values for their data type

GetLength Gets the number of elements in the specified dimension of an array

Copy Copies a section of one array to another arrayIndexOf Returns the index of the first occurenceLastIndexOf Returns the index of the last occurrence of the value

in a one-dimensional arrayLength Total number of elements in all the dimension of the

arraySort Sort the elements in a one dimensional array.

Q31 :- What are situations in which you can’t overload the procedure.Ans :- you can overload the procedure by varying one or more of following things with parameter.

1. Procedure modifier keyword such as public2. Argument names3. Argument modifier keyword such as byref and Optional4. The data type of the return value, since the return value can be ignored.

Q32. Differentiate Sub Procedures and Functions in Detail.

Ans. Sub Procedures

Sub procedures are methods which do not return a value. Each time when the Sub procedure is called the statements within it are executed until the matching End Sub is encountered. Sub Main(), the starting point of the program itself is a sub procedure. When the application starts execution, control is transferred to Main Sub procedure automatically which is called by default.

Example of a Sub Procedure

Module Module1Sub Main()'sub procedure Main() is called by defaultDisplay()'sub procedure display() which we are creatingEnd SubSub Display()System.Console.WriteLine("Using Sub Procedures")'executing sub procedure Display()End SubEnd Module

Functions

Function is a method which returns a value. Functions are used to evaluate data, make calculations or to transform data. Declaring a Function is similar to declaring a Sub procedure. Functions are declared with the Function keyword. The following code is an example on Functions:

Imports System.ConsoleModule Module1Sub Main()Write("Sum is" & " " & Add())'calling the functionEnd Sub

Page 26: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 26 of 35

Public Function Add() As Integer'declaring a function addDim i, j As Integer'declaring two integers and assigning values to themi = 10j = 20Return (i + j)'performing the sum of two integers and returning it's valueEnd FunctionEnd Module

Q33. Define Arrays in Detail.

Ans. Arrays are programming constructs that store data and allow us to access them by numeric index or subscript. Arrays helps us create shorter and simpler code in many situations. Arrays in Visual Basic .NET inherit from the Array class in the System namespace. All arrays in VB as zero based, meaning, the index of the first element is zero and they are numbered sequentially. You must specify the number of array elements by indicating the upper bound of the array. The upper bound is the numder that specifies the index of the last element of the array. Arrays are declared using Dim, ReDim, Static, Private, Public and Protected keywords. An array can have one dimension (liinear arrays) or more than one (multidimensional arrays). The dimensionality of an array refers to the number of subscripts used to identify an individual element. In Visual Basic we can specify up to 32 dimensions. Arrays do not have fixed size in Visual Basic.

The following code demonstrates arrays.

Imports System.ConsoleModule Module1Sub Main()Dim sport(5) As String'declaring an arraysport(0) = "Soccer"sport(1) = "Cricket"sport(2) = "Rugby"sport(3) = "Aussie Rules"sport(4) = "BasketBall"sport(5) = "Hockey"'storing values in the arrayWriteLine("Name of the Sport in the third location" & " " & sport(2))'displaying value from arrayEnd SubEnd Module

Q34. How to Reinitializing Arrays. What are Redim statements and Preserve Statements.

Ans. We can change the size of an array after creating them. The ReDim statement assigns a completely new array object to the specified array variable. You use ReDim statement to change the number of elements in an array. The following lines of code demonstrate that. This code reinitializes the Test array declared above. 

Dim Test(10) as Integer

Page 27: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 27 of 35

ReDim Test(25) as Integer'Reinitializing the array

When using the Redim statement all the data contained in the array is lost. If you want to preserve existing data when reinitializing an array then you should use the Preserve keyword which looks like this:

Dim Test() as Integer={1,3,5}'declares an array an initializes it with three membersReDim Preserve Test(25)'resizes the array and retains the the data in elements 0 to 2

Q35. What are Multidimensional Arrays? Explain.

Ans. All arrays which were mentioned above are one dimensional or linear arrays. There are two kinds of multidimensional arrays supported by the .NET framework: Rectangular arrays and Jagged arrays.

Rectangular arrays

Rectangular arrays are arrays in which each member of each dimension is extended in each other dimension by the same length. We declare a rectangular array by specifying additional dimensions at declaration. The following lines of code demonstrate the declaration of a multidimensional array.

Dim rectArray(4, 2) As Integer'declares an array of 5 by 3 members which is a 15 member arrayDim rectArray(,) As Integer = {{1, 2, 3}, {12, 13, 14}, {11, 10, 9}}'setting initial values

Jagged Arrays

Another type of multidimensional array, Jagged Array, is an array of arrays in which the length of each array can differ. Example where this array can be used is to create a table in which the number of columns differ in each row. Say, if row1 has 3 columns, row2 has 3 columns then row3 can have 4 columns, row4 can have 5 columns and so on. The following code demonstrates jagged arrays.

Dim colors(2)() as String'declaring an array of 3 arrayscolors(0)=New String(){"Red","blue","Green"}initializing the first array to 3 members and setting valuescolors(1)=New String(){"Yellow","Purple","Green","Violet"}initializing the second array to 4 members and setting valuescolors(2)=New String(){"Red","Black","White","Grey","Aqua"}initializing the third array to 5 members and setting values

Q36. discuss Imports Statement

Page 28: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 28 of 35

Ans. The Imports statement is used to import namespaces. Using this statement prevents you to list the entire namespace when you refer to them.

Example of Imports Statement

The following code imports the namespace System.Console and uses the methods of that namespace preventing us to refer to it every time we need a method of this namespace.

Imports System.ConsoleModule Module1

Sub Main()Write("Imports Statement")WriteLine("Using Import")End Sub

End Module

The above two methods without an imports statement would look like this: System.Console.Write("Imports Statement") and  System.Console.WriteLine("Using Import")

Q37 - What is use of Parameter Array and also specify the rules applied to declare parameter array?Ans :- Parameter array is used to specify the unlimited number of parameters at the time of

calling the procedure . The parameter array is always the last argument in the procedure , and is signified by the ParameterArray keyword.The following rules are applied in declaring parameter array with the procedure

1. A procedure can have only one parameter array, and it must be the last parameter in the procedure definition.

2. the parameter array must be passed by the value. It is good programming practice to explicitly include the ByVal keyword in the procedure definition .

3. the code within the procedure must treat the parameter array as one-dimensional array.

4. the parameter array is automatically optional . its default value is an empty one –dimensional array.

all arguments preceding array must be required . the parameter array must be the only optional argument.

Q38: - How many types of Helper form provided by vb.NET?Ans: - There are three types of helper forms provided by the vb.Net.

1. MessageBox :- Includes text that is either informative or a question, and buttons such as OK ,Yes, No, Cancel and so on for the application user’s response and to close the message box. It is modal

2. Dialog box : - Similar to a message box , it also is modal , but may contain text boxes,check boxes , drop-down list and other controls. The print dialog box displayed is one of the example.

3. Owned form :- Similar to a dialog box, it also may contain controls , but unlike a dialog box , an owned form is modeless.

Q39 :- How can you define menu in vb.net?Ans: - the menu provides a GUI through which the application user can issue commands to the

application. You can add menu to a windows form either at design time in the windows form designer or programmatically at runtime.

By adding main menu component to your windows forms and then add menu item to it.Menu at runtimeYou can add a menu programmatically to window form in several steps

1. create a new public procedure, which in this example will be called

Page 29: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 29 of 35

e. gpublic sub addMenu()

dim mnufile as new MainMenu()me.Menu=mnufiledim mnuitemfile as new menuitem(“&file”)dim mnuitemnew as new menuitem(“&new”)menfile.menuitems.add(mnuitemfile)menuitemfile.menuitem.add(mnuitemnew)

end sub

2. called the addmenu() procedure of the form load event of the forme.g

private sub form1_load(ByVal sender as System.object,_byVal e as System.EventArgs) handles MyBase.loadaddMenu()end sub

Q40 :- Define Context Menu?Ans : - Context menu are displayed when the user clicks the right mouse button over the area of

the form, or over a control on the form. Shortcut menus also are called context menus, because the particular menu items displayed depend on the context.Creating context Menu

1. add Context menu to window form from the tool box.2. Associate the context menu with the form or a control on the form by choosing

the context menu object from the drop-down list in that form , or control’s context menu property in the properties window.

Q41 :- How many types of error provided by VB.net?Ans : - There are three types of error

1. Syntax Error2. Runtime error3. Logic error1. Syntax error : - Syntax error are the failure of your code to meet the

requirements of the visual basic. Net programming language. They includes misspelt variable names, call with wrong parameters to a procedure etc.

2. Runtime error : - Runtime errors are those that appear while your application is running often bringing your application to the termination reffered to a “crash” . to execute the program successfully we have to handle these error . These errors also known as exceptions.

3. Logic Errors : - Logical errors do not cause your program to terminate but produce wrong output. Such 2+2 equaling 22 instead of 4. etc.

Q42. Define Debugging in Detail.Ans. Debugging is the art of identifying and riding your application of programming errors, often

referred as bugs. While bugs may cause exceptions to all bugs do. This is not necessarily good news. The cause of incorrect output often is far more difficult to spot than errors that cause exceptions. You generally kow the point in your program where it came to a screening halt. However, the cause of incorrect output at the end of your program could be far earlier in the program. Debugging is also useful for exceptions.

Q43 :- Define all the debugging tools provided by vb.net?Ans :- visual basic .net provides you with debugging tools that you can use to view, and in some

instances, change the value of variables and expression . the debugging tools include1. DataTips popup2. Autos window3. Local window4. The window5. watch window6. Quick Watch Dialog box7. Call stack window

Page 30: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 30 of 35

DataTips Data Tips appear in the break mode when mouse pointer is placed on the line. Data tips are easy to use but somewhat limited. Unlike many other debugging tools that can be displayed both when the debugger is running and when it is the break mode.Auto windowThe Auto window displays variables used in the current statement, which is the statement that will be executed next if execution continues. The auto window also will display variables used in three statements on either side of the current statement. The This window The strangely named This window enables you to examine the data member of the object associated with the current method. “ This “ comes from other languages. This is the name of a pointer to the current instance of a class.The Watch windowYou can use the watch window to evaluate variables and expression and view the results, and also to edit the value of a variable.The quickwatch dialog boxThe quickwatch dialog box to as its name implies ,. Quickly evaluate a variable or expression. The quickwatch dialog box provides a quicker, simpler way of evaluating or editing a single variable or expression. You can only open the quickwatch dialogBox if the debugger is in break mode.The call stack windowThe call stack window displays the name of each procedure and the programming language it is written in.the procedure name may be accompanied by optional information, such as module name, line number, byte offset, and parameter names., types and values.

Q44. What is the purpose of Menu bars in an user interface? How the menu items can be modified and deleted?

Ans. Menu bar is an essential component of the (GUI) Graphical user Interface. Using menu bar user can create different menus for different option and can group the related options in the same menu.

e.g.In Microsoft word there are 9 menus in menu bar, which contains several options. One can select required option from the related menu. Suppose you have to save a file of Ms-word. For this you will choose save option from the file menu.

*To modify a menu item click on the item in design view and modify it according to need.

*To delete a men item in design view click on it and press delete button from keyboard to delete it.

Q45 Explain how checkboxes are differ from option buttons? Which one to proper it user has to select more them one choice.Ans. Checkboxes and optim buttons are not only having difference appearance but

the major difference is that in group of checkboxes the user can select as many options (choices) he/she want. But when there options are provided with options buttons then the user can select only one from the given. e.g.

Info

Name

Fname

Gender θ male θ Female

Hobbies Cricket Music

Movies Dance

√ √

Page 31: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 31 of 35

In the above form user can select only one option from the gender (male/female), which are provided with option buttons. But user can select many options from the hobbies, which are provided with checkboxes.

The checkbox is preferred when the user has to select more than one choice

Q46 Write down the steps to create a web control.Ans. In addition to built in web form controls you may want to create a new web form control

right from the scratch. To do this you will be using the web control class library.The process of creating a new web control consists of the following steps in

brief.

Create a new project of type web control library by clicking new project / web control library.

In the class created for the project, place the code under the render method to make the control perform an action: This typically involve, creations appropriate HTML to render the controls interface.

If the control needs any additional properties on methods besides the standard ones inherited from he system. Web.ui. Web controls class, then these members should be coded a necessary.

Build the project to create a .DLL for the control. Create a new web application project by clicking project/New/web

application to test the control. Reference the control by clicking project/add reference in the project and

drag it on the page for testing.Q47. Define Winforms.Ans Winforms are essentially a more advanced version of forms as you know them today.

Presently they ar bundled with a load of functionality that enables you to build some advances screens well, lets explore the windows forms....

1. launch VB.NET2. on your start page, click create new project.3. Under visual basic projects, select windows application4. change the name and location, if required.5. click the ok button. Now you will see the windows form.

Look at the solution explorer. Did you notice that the form filename is forml.vb? All visual basic code whether forms or class modules are stored as .VB files. The code inside that file describes what it is and what it does.

Q48. What are the various control statements in VB.net!Ans. Control structure available in VB.net are classified into two categories:-

Decision controlIteration control. (loop structure)a. Decision control: - VB.net provides the following if statements for

decision control.a. If.... then statement: - The if these statement is used when there is/are not

statement (s) to executes when the given condition is false:Syntax:-If [condition] then------------------------------------------

End if

Page 32: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 32 of 35

b. If.... then...else statement: - The if...then...else statement is used when there is/are the statement (s) to execute for both true and false condition.

If [condition] Then-----code--------------------else

------code-------End if

c. If..elseif statement: - You are the if....elseif statements if you have more than two alternatives blocks of code.

The syntax of an if = elseif statement isIf [condition] Then[code]elseif [condition] Then[code]else[code]End if

b. Iteration control: - (loop structure) loop structure allow you to execute one or more lines of code repetitious. The loop structures supported by VB.net are.

a. For next: - the for next loop is used to repeat the lines of code for the known no. of times.

Syntax: - for counts = start to end [step][statements]next [ counter]

b. While----End while: - This statement repeats the execution of statement (s) as long as given condition is true:-

Syntax:-While condition[statements]End While

c. Do...loop: - The Do statement comes in two varieties, one testing conditions at the top of the statement, the other at the bottom. When it tests the condition at the top of the statement. The Do statement is quite similar to the while = End while statement.

Syntax:-Do {while | until} condition

[statements]loop

Do[statements]Loop {while | until} condition.

Q49. Discuss option strict, option explicit and option compare.Ans. Option strict: - when this option is on , then you can not declare a variable without

specifying its data type i.e. when you need a variable you have to declare it with dim keyword and has to specify its data type also. By defaults this option is set to off.

e.g.Dim name as string

Option compare: - Whenever you compare two strings in VB.net.e.g – HELLO with hello then it will result in that hello is great than HELLO. Because it is care sensitive while compare two strings. But when we want to make VB.net care insentive then we use the option compare.

There are two types of option compare statements

Page 33: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 33 of 35

c. Option compare Binary (care sensitive) by defaultsd. Option compare Text (care insensitive)

Q50. Write Steps to Create Context Menus.Ans. Context menu are displayed when the user clicks the right mouse button over the area of the

form, or over a control on the form. Shortcut menus also are called context menus, because the particular menu items displayed depend on the context.The steps to create a Context Menu are as follows:

1. In the Window form Designer open the form to which you wish to add the context menu.

2. Double-click the context menu component in the toolbox. This will add the context menu component to the form.

3. Associate the context menu with the form or a control on the form by choosing the contextMenu object from the Drop-Down list in that form, or control’s ContextMenu property in the property window.

Q51. Define Exception Handling in Detail.

Ans. Exceptions are runtime errors that occur when a program is running and causes the program to abort without execution. Such kind of situations can be handled using Exception Handling. By placing specific lines of code in the application we can handle most of the errors that we may encounter and we can enable the application to continue running. VB .NET supports two ways to handle exceptions, Unstructured exception Handling using the on error goto statement and Structured exception handling using Try....Catch.....Finally

Let's look at the new kind of exception handling introduced in VB .NET which is the Structured Exception Handling. VB .NET uses Try....Catch....Finally block type exception handling. The syntax looks like this:

Module Module1

Sub Main()

Try--Catch e as Exception

--Finally

End Try

End Sub

End Module

Example

Imports System.ConsoleModule Module1Sub Main()Dim a = 0, b = 1, c As IntegerTry

Page 34: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 34 of 35

c = b / a'the above line throws an exceptionWriteLine("C is " & c)Catch e As ExceptionWriteLine(e)'catching the exceptionEnd TryEnd Sub

End ModuleQ52. Discuss Error Handling mechanism in Vb .Net.

Ans. Visual Basic .NET or Visual Basic 2005 offers structured exception handling that provides a powerful, more readable alternative to "On Error Goto" error handling, which is available in previous versions of Microsoft Visual Basic. Structured exception handling is more powerful because it allows you to nest error handlers inside other error handlers within the same procedure. Furthermore, structured exception handling uses a block syntax similar to the If...Else...End If statement. This makes Visual Basic .NET and Visual Basic 2005 code more readable and easier to maintain.

The Try...Catch...Finally control structure is fundamental to structured

exception handling. It tests a piece of code, filters exceptions created by the

execution of that code, and reacts differently based on the type of thrown

exception.

Try...Catch...Finally control structures test a piece of code and direct how the

application should handle various categories of error. Each of the structure's

three constituent parts plays a specific role in this process.

The Try statement provides the code that is being tested for exceptions. Catch clauses identify blocks of code that are associated with specific

exceptions. A Catch When block directs the code to execute under specific

circumstances. A Catch without a When clause reacts to any exception.

Therefore, your code might hold a series of specific Catch...When statements, each reacting to a specific type of exception, followed by a

general Catch block that reacts to any exceptions that have not been

intercepted by the preceding Catch...When clauses.

The Finally statement contains code that executes regardless of whether or not an exception occurs within the Try block. A Finally statement will execute even after an Exit Try or Exit Sub. This code often performs clean-up tasks, such as closing files or clearing buffers.

Q53. How can you define multiple catch blocks in structured error handling? explain.Ans.

Multiple Catch Blocks A try block can throw multiple exceptions, which can handle by using multiple catch blocks. Remember that more specialized catch block should come before a generalized one. Otherwise the compiler will show a compilation error.

//VB.NET: Exception Handling: Multiple catchImports SystemClass MyClientPublic Shared Sub Main()

Page 35: What do you mean by · Web viewQ1. What do you mean by .NET framework? Ans. The .NET framework is as much the central nervous system of the .NET languages provides interoperability

Vaishnoo Maa Computers[Cal-c] A Study Centre of PTUSubject:- Question Bank of Vb.Net Page No 35 of 35

Dim x As Integer = 0Dim div As Integer = 0Trydiv = 100 / xConsole.WriteLine("Not executed line")Catch de As DivideByZeroExceptionConsole.WriteLine("DivideByZeroException")Catch ee As ExceptionConsole.WriteLine("Exception")FinallyConsole.WriteLine("Finally Block")End TryConsole.WriteLine("Result is {0}", div)End Sub 'MainEnd Class 'MyClient

Q54. Discuss Try-catch-finally block structure for exception handling in VB.net.

Ans. Try...Catch...Finally control structures test a piece of code and direct how the

application should handle various categories of error. Each of the structure's three

constituent parts plays a specific role in this process.

The Try statement provides the code that is being tested for exceptions. Catch clauses identify blocks of code that are associated with specific

exceptions. A Catch When block directs the code to execute under specific

circumstances. A Catch without a When clause reacts to any exception.

Therefore, your code might hold a series of specific Catch...When statements, each reacting to a specific type of exception, followed by a

general Catch block that reacts to any exceptions that have not been

intercepted by the preceding Catch...When clauses. The Finally statement contains code that executes regardless of whether or

not an exception occurs within the Try block. A Finally statement will

execute even after an Exit Try or Exit Sub. This code often performs clean-

up tasks, such as closing files or clearing buffers.