0% found this document useful (0 votes)
6 views10 pages

Internal Assignment

The document discusses Event-Driven Programming, highlighting its reliance on events and event handlers to dictate application behavior, particularly in GUI applications. It also covers decision-making statements in VB.NET, emphasizing various conditional structures like If statements and Select Case statements. Additionally, the document explains the Just-In-Time (JIT) Compiler's role in the .NET framework, detailing its benefits such as performance optimization, platform independence, and enhanced security.

Uploaded by

rishuraj77396747
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views10 pages

Internal Assignment

The document discusses Event-Driven Programming, highlighting its reliance on events and event handlers to dictate application behavior, particularly in GUI applications. It also covers decision-making statements in VB.NET, emphasizing various conditional structures like If statements and Select Case statements. Additionally, the document explains the Just-In-Time (JIT) Compiler's role in the .NET framework, detailing its benefits such as performance optimization, platform independence, and enhanced security.

Uploaded by

rishuraj77396747
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

INTERNAL ASSIGNMENT

SET-I

Q. No. 1.

Ans. No. 1. Event-Driven Programming


Event-Driven Programming is a programming model in which the behavior of an application
is programmed in response to events such as user actions (mouse clicks, key presses), sensor
outputs, or messages from other programs/ threads. While procedural programming is
executed in a linear manner, event-driven programming executes portions of code (known it's
handling) when the corresponding events—the events are being triggered by an user's action
with the return behaviors- happens.

Fundamentals: Events And Their Handlers

An event is an indication that something has occurred. Typical actions in the software realm
might be when a user clicks on a button, presses a key or changes a text field, for example,
or when system notification gets generated. As mentioned in the transcript, when a web form
fields like I'm filling it interacts with your users clicking a “Save” button is actually firing a
click event and typing in text box may fire an event of change of text.

An event handler (or event listener) is a callback function, that is created to be executed in
response to an action. Developers bind event handlers to events in order to specify how the
program should behave. For example, the click event on a “Save” button might have a
handler that includes code to save all form data, while a “Cancel” button might clear out all
the form fields in its click event handler. Likewise, a text change event on a name field might
have an handler that looks at the input (e.g., disallowing numbers like "1234") and responds
accordingly.
Implementation and Advantages

Graphical user interface (GUI) applications are a typical example of how event, driven
programming is utilized in real life. Programmers in development environments such as
Microsoft Visual Studio can visually design forms by dragging and dropping controls (e. g. ,
text boxes, buttons) onto a container. With very few lines of code, each control can then be
linked to different event handlers.

The programming model of event-driven programming comes with many advantages.


1. Flexibility: The model permits dynamic response to the application's input and/or
internal events at run time.

2. Ideal for GUI Applications: User interaction will typically take place through an
event-driven system. While creating GUIs for applications, the developer defines an
event for each control's execution.

3. Simplicity in Programming: The user provides a visual representation of the


controls and is able to modify_property values for those controls via the property
editor. As a result, the programming is very easy to understand.

4. Ease of Development: The programmer can write code for each interaction with the
application independently of other events. For example, when code is being written
to validate text entered into an input box, the event-driven programming model
supports each control being attached to one event.

Q. No. 2.
Ans. No. 2. Decision-Making Statements in [Link]

Statements that make decisions, often referred to as decision-making statements or control


statements, are an essential building block of VB. NET that enable a program to perform
different actions depending on whether the conditions specified by programmers evaluates to
true or false. They determine the direction of program execution by making choices, causing
the programme to behave differently for different data input and states. Similarly these
statements decide the flow of a program. These are used to execute a single statement or
group of statements / block only if certain condition is true or satisfied.
The most common decision-making statements used in VB. NET which includes the If
statement family and the Select Case statement.
1. If…Then Statement

The If...Then: This is straight to the point. It tests a boolean, logical and relational
condition. If the condition is true, then the program executes the statement (or block of
statements) that follows the if statement. If the condition is true, the entire block is
included.

The syntax is:

If condition Then

' Statement(s) to execute if true


End If

Example
If a > 10 Then
[Link]("a is greater than 10")

End If

2. If…Then…Else Statement

The If...Then...Else Statement: is an extension of the If...Then statement, which includes


an alternative course of action if the condition is either True or False. The statement
guarantees that one of the two blocks will always be executed

The syntax is:

If a < 20 Then

[Link]("a is less than 20")


Else

[Link]("a is not less than 20")

End If

Example

If a < 20 Then

[Link]("a is less than 20")

Else
[Link]("a is greater than or equal to 20")

End If

3. If…Then…ElseIf Statement

The If...Then...ElseIf Statement: This is a sequence of else-if tests that test many
mutually exclusive conditions. It is "implemented more or less as though the conditions
were 'else-if' statements" Execution begins at the top, and the first condition that is true
has its block executed. The last Else block is optional and acts as a default if none of the
previous conditions are true.

The syntax is:

If condition1 Then
' Executes when condition1 is true

ElseIf condition2 Then

' Executes when condition2 is true

Else
' Executes if none of the above are true
End If

Example

If marks >= 70 Then

[Link]("First Division")
ElseIf marks >= 45 Then

[Link]("Second Division")

Else

[Link]("Fail")

End If

4. Nested If Statements
A nested if statement is an if statement inside another if statement or an else block.
Nested if statements help make more complex decisions; they allow you to have
multiple layers of conditions that must be met.

Syntax

If a = 300 Then
If b = 400 Then
[Link]("a is 300 and b is 400")
End If
End If

5. Select Case Statement


A select case statement is a way to replace large chains of if...else if statements by
comparing one variable or expression against many fixed values. This makes
information more readable and therefore easier to understand using select case
statements.

Syntax

Dim op As Integer = 4

Select Case op

Case 1
[Link]("Good Morning")

Case 2

[Link]("Good Afternoon")
Case 3
[Link]("Good Evening")

Case 4

[Link]("Good Night")

Case Else
[Link]("Enter the correct choice")

End Select

Q.3.

[Link].3.

One of the major dynamic components of the .NET Runtime Environment is the Just-In-Time
(JIT) Compiler. This component is responsible for translating portable, intermediate codes
into executable machine code that is efficient and easy to run. In a way, it provides a bridge
between compiling for a platform-independent system and then executing it on that platform.
Hence the core concept of .NET that demonstrates "write once, run anywhere" allows for
high performance as well as simplicity in development.

Function and Working Mechanism:

The .NET framework, through the .NET Common Language Runtime (CLR) to execute an
application written in C#, [Link], etc. The source code is compiled by a language compiler
into an intermediate language or CIL (common language) or MSIL (Microsoft Intermediate).
The CIL code is compiled into an EXE/DLL, which is a dynamic link library file. When a
program is started, the CLR will load the EXE/DLL, and the methods will be compiled Just-
in-Time (JIT) to convert CIL code into native machine code that is optimised for the CPU
architecture of the machine (x86, x64, ARM). The code is saved in memory so all future calls
to the same method will require no compilation and will be executed directly from memory,
making it possible to get a good tradeoff between start-up time and run-time performance.

Importance and Key Benefits:

Performance Optimization: The JIT compiler benefits from a rich runtime context and,
unlike a static Ahead, Of, Time (AOT) compiler, can perform additional advanced
optimizations specifically tailored to the hardware on which it runs, e. g. CPU instruction set
optimizations. Thereby, features like hotspot detection allow it to recognize and thus optimize
those code paths that are most frequently executed, leading to superior long, running
application performance. Hence, this dynamic optimization is a major factor in the superiority
of JIT compilation over statically compiled code.

• Platform Independence and Portability: The JIT compiler is the main source of .
NET's platform, agnosticises. Because the first compilation output is neutral CIL, the
very same assembly can be used on Windows, Linux, and macOS systems. The last,
platform, specific compilation is hence done by the JIT compiler within the CLR of
the target machine. In this way, the development environment is completely
independent of the deployment environment.

• Enhanced Security: The JIT compiler is the one that implements security measures
last but not least. It not only performs the compilation but also can perform the
security verification of CIL code by type, checking it and by verifying that no buffer
overflows or memory accesses to invalid locations occur. The runtime verification
experienced by the JIT, compiled code adds a very strong security layer that is not so
easy to accomplish for fully pre, compiled native code.

• Maintenance and Deployment that are Efficient: Since applications are distributed
in CIL, updates and patches are often only in the form of a new version that should
be dispatched to users. This facilitates a maintenance model that is much more
efficient and accessible, which can also lead to the easy deployment of continuous
delivery strategies.

SET-II

Q.4.

[Link].4.

1. Data Adapter
In the . NET Framework, the Data Adapter is a key ADO. NET component that links a
database with in, memory data objects like DataSet or DataTable. Operating on a
disconnected architecture model, it ensures that the database connection is open only
when necessary. The Data Adapter is equipped with a command to execute SQL
statements and a connection object to open the database. The Fill() method of the
Dataset or DataTable is the one that gets the data loaded from the database. In
addition, it has the SelectCommand, Insert Command, Update Command, and Delete
Command properties. The Update() method is the one that, after the Dataset has been
modified, goes back to the database to apply the changes and thus keeps the data
synchronized between the application and the database. Consequently, this approach
to data handling is not only efficient and flexible but also scalable to enterprise
applications.
2. Dataset
A Dataset is essentially a collection of data tables being held in the memory of the
computer, much like a database which is essentially a collection of different types
(groups) of data or tables. A Dataset has the ability to hold a single DataTable or many
DataTables (or also known as child DataTables). Each DataTable contains rows of
information and columns of information. A DataTable can contain student information
such as ID number, Name and Class or could contain other types of information as
well. It provides an application the ability to access data from a database, store that
data in the computer's memory for future processing, as well as give an application
the ability to use that data without being connected to the database. In addition, by
using Dataset, applications are able to manage, view, and manipulate records that
have been stored in the memory of the computer.

3. Overloading
Overloaded methods or operators share a common name, but have different types,
arguments (number) or order of arguments. In the instance of method overloading, it
allows you to create multiple methods within a class that are invoked by the same
method name. They perform a particular operation based on the method signature.
The operator overloading concept allows an operator to perform various operations
depending on the type of data being processed. For example, the '+' operator would
allow for two integers to be added, or for two strings to be concatenated.

4. Encapsulation
Encapsulation entails combining and containing an object's data and functions into
one unit (often called a class). Some aspects of an object should be restricted from
outside access to prevent users from accidentally modifying them; these are typically
designated as private properties. In order to provide users with safe access to the
object's data, you may provide 'get' and 'set' methods.

Q.5.

[Link].5.

In [Link], Exception handling is a way to deal with problems that happen in programs
while they're being used. These problems are called exceptions. In older programming
languages, when a problem happened, programmers would get information back that would
tell them that something went wrong (i.e., "error codes" or "error flags"). In .NET, instead of
using these kinds of messages, .NET has an object-oriented exception handling system,
which provides better, more structured, and more dependable methods for handling
exceptions than other programming languages. Therefore, in [Link] when talking about
how to handle unusual conditions, it has become customary to refer to these as "exceptions"
instead of the more traditional "errors".
The exception-handling mechanism is designed to make it easier for software developers to
create uniformly structured methods of raising, trapping and handling exceptions so that
developers can gracefully recover from an unhandled exception and keep their application
running instead of crashing. In [Link], the exception is a runtime error that results from a
programmer using an illegal argument or an illegal state. The general procedure for [Link]
handling of exceptions can be broken down into three steps:

1. Raising (Throwing) an exception


2. Catching the exception
3. Handling or processing the exception
In [Link], exceptions are a base class called [Link]. Generally, [Link] defines
two types of exceptions:
1. Internal Exceptions
These are built-in exceptions defined as part of the .NET framework and trap general
runtime errors such as DivideByZero, NullReference, FileNotFound, and
ArgumentException. Internal exceptions are common to all applications and are
examples of issues that can arise from a programmer coding to a platform level or at
runtime.
2. Application Exceptions
User-defined exceptions are created by developers to define application or business
logic specific to their application and to provide detailed information related to the
error, thus making it easier for users and support personnel to resolve issues. User-
defined exceptions are a subtype of [Link].

[Link] contains four core keywords used in handling exceptions:

1. Try is the code that might throw an exception.


2. Catch handles exceptions thrown from code in Try. You may have as many Catch
blocks as needed to handle different exception types.
3. Finally executes code that is executed regardless of whether or not an exception
occurred. You usually use this for clean-up purposes (for example, closing files,
releasing resources).
4. Throw allows you to throw an exception. It can throw a new exception or rethrow an
existing exception to the calling method.

Benefits of Using Exception Handling:

• Provides a clear separation between the primary flow of control in a program and the
error handling components.
• Prevents the abnormal termination of an application.
• Increases the Reliability, Stability and Maintainability of the Software Product.
• Simplifies Debugging and Error Reporting.
• Creates a More Meaningful Error Message to Improve the Overall User Experience.
Q.6.
[Link].6.

Object-oriented programming (OOP) contains many concepts, including inheritance. In


[Link] (Visual Basic .NET), Inheritance allows one class (the child or derived class) to gain
features from another class (the parent, base or super class). Inheritance allows the child class
to reuse the parent class's functionality, reducing the amount of duplicate code and allowing
the programmer to create models of real life using the "is a" concept in which a derived class
is a more specific/derived instance of its parent class.

Class Terminology:
The base class contains the members; the derived class derives members from the base. By
creating a derived/class based on a base class, the derived class will automatically have
access to the data members and methods of the base class, however, the derived class can add
or remove members and modify behaviour to make it more specialised.

Types and [Link] features

[Link] has three forms of inheritance: single inheritance (a class inherits from one base
class), multilevel inheritance (a base class has multiple derived classes), and hierarchical
inheritance (there are multiple classes that inherit from the same base class). [Link] does
not support multiple class inheritance; however, it allows implementing multiple derived
classes through the use of interfaces to support multiple inheritance. Therefore, [Link] only
allows a base class to define an interface contract and derives from only one direct base class.

Important features and keywords in [Link]:

• Inherits — to specify the derived class's parent class


• Overridable and Overrides — to enable derived class substitution of the base class
implementation
• NotOverridable — used to prevent a derived class from overriding a method
• MustInherit — indicates an abstract/base class that cannot be instantiated
• MustOverride — provides the derived class with an abstract base method
• Interface and Implements — enables classes to implement various contracts through
an interface.

Simple example

Public Class Animal

Public Overridable Sub Speak()

[Link]("Some sound")
End Sub

End Class

Public Class Dog

Inherits Animal

Public Overrides Sub Speak()

[Link]("Bark")
End Sub

End Class

Here Dog reuses Animal code and customizes Speak() — demonstrating reuse and
specialization.
Advantage

1. Code reuse: Code reuse through inheritance allows programmers to reuse existing
code in multiple locations.
2. Maintenance: Maintenance is automated, as changes made to the base class are
automatically updated to all derived classes.
3. Logical Structure: Hierarchical models allow developers to easily view and
understand the relationship between entities within the domain (i.e., Vehicle → Car →
ElectricCar).
4. Extensibility: It is easy for developers to extend existing code in order to create new
derived types.

Conclusion

Inheritance is one of the fundamental components of OOP that simplifies the process of
application development through the ability to reuse existing code, enforce logical
hierarchies, and support polymorphic behavior. The combination of inheritance with
interfaces and the keywords provided in [Link] (Inherits, Overrides, MustInherit, etc.) will
facilitate the creation of clean, extensible, and maintainable applications.

You might also like