All Unit Two Marks Questions
All Unit Two Marks Questions
All Unit Two Marks Questions
JIT is the process of compiling MSIL code units just when needed at
runtime. The JIT compiler in the Common Language Runtime (CLR) compiles
MSIL instructions to native machine code as a .NET application is being
executed. Compilation occurs when a method is called and is not compiled more
than once during program execution; because, JIT‐compiled code is cached in
memory.
15. What is Managed code?
Code that is executed by the Common Language Runtime (CLR) is called
managed code. Managed code provides metadata to enable the CLR to
handle exceptions, locate methods encoded in assembly modules, and
manage security information. Managed code can access both managed data
and unmanaged data.
16. What is unmanaged code?
It is, also called unsafe code, code that executes outside of the control of the
Common Language Runtime (CLR). Unmanaged code may perform unsafe
operations such as pointer arithmetic. Unmanaged code is used for accessing
unmanaged memory, calling Windows APIs, interfacing to COM components,
and coding performance‐critical methods which avoid the overhead of the CLR.
17. What is Managed data?
Microsoft.CSharp
Contains classes that support compilation and code generation using the C#
language.
Microsoft.JScript
Contains classes that support compilation and code generation using the
JScript language.
Microsoft.VisualBasic
Contains classes that support compilation and code generation using the
Visual Basic .NET language.
System.CodeDom
Contains classes that can be used to represent the elements and structure of a
source code document.
27. What are the uses of managed code?
Garbage collection.
Use of delegates rather than function pointers for increased type safety and
security. Function pointers are available through the use of the unsafe C#
keyword and the /unsafe option of the C# compiler (Csc.exe) for
unmanaged code and data.
Just - in - Time (JIT) compiler, which compiles MSIL into native code that is
specific to the OS and machine architecture being targeted.
UNIT II
.NET Languages
1. What Is C#?
• Java has not retained some powerful C++ features such as operator
overloading.
• It also lacks inter‐operability with code developed in other languages.
11. What are important features of C#, which are adopted from other
languages?
The statements which are not included for compilation by the compiler are
called as comments. They are used to enhance readability and understanding of
code. C# permits two types of comments, namely:
Single Line Comments
Begins with a double backslash (//) symbol. Ex: //Main method begins Multi
Line Comments
This starts with /* characters and terminates with */. Ex: /* Program - Testing
Delegates
Date - 09.10.08
Developer - Kumaran */
14. State th e C# Program Structure.
C# is a freeform language. So it does not care where on the line the code is
begins.
Ex:
System.Console.WriteLine(“Hello ECE”); Can be written as
System.Console.WriteLine (“Hello ECE”);
Can be written as
System.Console.WriteLine
(
“Hello ECE”
)
;
16. What are the types of tokens available in C#?
1. Comments
2. white spaces
3. tokens
4. preprocessing directives
20. What is line terminator in C#?
Punctuators are symbols used for grouping and separating code. They
define the shape and function of a program. Punctuators or Separators in C#
include:
Parentheses ()
Braces { }
Brackets []
Semicolon ;
Colon :
Comma ,
Period .
22. What is stack memory and heap memory?
It includes simple data types such as enum, struct, char, bool, int, float, etc.
Value type variable directly contain data since memory is allocated on stack.
Operation on one variable does not affect the other value type variable. It provides
efficient access and faster execution by stack allocation.
24. What is reference type?
Constants make programs easier to read and understand Easy to modify the
program. They minimize accidental errors, like attempting to assign values
to some variables which are expected to be constants.
33. Classify the C# operators.
Output parameters are used to pass results back to the calling method. This is
achieved by declaring the parameters with an out keyword. Similar to reference
parameter, an output parameter does not create a new storage location. Instead,
it becomes an alias to the parameter in the calling method. When a formal
parameter is declared as out, the corresponding actual parameter in the
calling method must also be declared as out.
Ex:
using System;
class Output
{
static void addition (int a , int b, out int result)
{
result = a + b;
}
public static void Main()
{
int x = 5, y = 8, sum;
addition(x, y, out sum);
Console.WriteLine(“The sum of {0} and {1} is {2}”, x, y, sum);
}
}
40. Write a short note on parameter arrays (OR) params keyword (OR)
variable argument list
Any method can return only one value if the return type is other than
void. But in C#, it is possible to return more than one value from the
program using out parameter. For example,
using System;
class ReturnTest
{
static int test(int a, out int b)
{
b = a + a;
return ++a;
}
public static void Main()
{
int x = 10, y;
Console.WriteLine(“The value of x is {0}”, test(x,out y));
Console.WriteLine(“The value of y is {0}”, y);
}
}
Output:
The value of x is 11
The value of y is 20
43. What is a class?
Encapsulation provides the ability to hide the internal details of an object from
its users. The outside user may not be able to change the state of an object
directly. However, the state of an object may be altered indirectly using what are
known accessor and mutator methods. The concept of encapsulation is
also known as data hiding or information hiding.
45. What is inheritance?
Inheritance is the concept used to build new classes using the existing
class definitions. Through inheritance a class can be modified easily. The
original class is known as base or parent class and the modified one is
known as derived class or subclass or child class. The concept of inheritance
facilitates the reusuability of existing code and thus improves the integrity of
programs and productivity of programmers.
46. What is polymorphism?
1. A derived class extends its direct base class. It can add new members
to those it inherits.However, it cannot change or remove the definition on an
inherited member.
2. Constructor and destructors are not inherited. All other members,
regardless of their declared accessibility in base class, are inherited.
3. All instance of a class contains a copy of all instance fields declared in the
class and its base classes.
4. A derived class can hide an inherited member.
5. A derived class can override an inherited member.
48. Advantages of Inheritance
private - Member is accessible only within the class containing the member.
public - Member is accessible from anywhere outside the class as well. It
is also accessible in derived classes.
protected - Member is visible only to its own class and its derived class.
internal - Member is available within the assembly or component that is being
created but not to the clients of the component.
protected internal - Available in the containing program or assembly and in the
derived classes.
50. What are the features of a constructor?
The name of the destructor is same as the class name. The name is
preceded by ~. It is always public. There is no parameter in the signature. There is
no return type.
56. What are properties?
Properties have the same capabilities as accessor methods, but are much
more elegant and simple to use. Using a property a programmer can get access to
data members easily. These are sometimes referred as “smart fields”.
Ex:
class TestProp
{
private int n;
public int number //property defines getter and setter methods
{
get
{
return n;
}
set
{
number = value;
}
}
}
57. What are the powerful features of properties?
Other than fetching the value of a variable, a get clause uses code to
calculate the value of the property using other fields and returns the results. This
means that properties are not simply tied to data members and they can also
represent dynamic data. Like methods, properties are inheritable. The modifiers
abstract, virtual, new and override may be used with them appropriately, so
the derived classes can implement their own versions of properties.
Indexers are location indicators and are used to access class objects,
just like accessing elements in an array. They are useful in cases where a class
is a container for other objects. These are referred as “smart arrays”.
Ex:
public int this [int index]
{
get
{
//return desired data
}
set
{
//set desired data
}
}
1. The direct base class of a derived class must be at least as accessible as the
derived class itself.
2. Accessibility domain of a member is never larger that that of the class
containing it.
3. The return type of method must be at least as accessible as the method itself.
62. What are the Characteristics of the Override?
1. Delegate declaration
2. Delegate methods definition
3. Delegate instantiation
4. Delegate invocation
74. Write a note on delegates.
Error is a mistake that can make a program go wrong. An error may produce
an incorrect output or may terminate the execution of the program abruptly or
even may cause the system to crash. There are two types of error:
1. Compiler‐time errors 2. Run‐time errors
78. Write some examples for run‐time errors.
Property
A property is identified by its name
A property is accessed through the property name
A property can be static.
Indexer
An indexer is identified by its signature
An indexer element is accessed through the subscripted expression with the
object name as the array name.
Indexer is always as instance member
83. What is Override?
.NET Frame work includes two languages which are language to IL compilers
and in this C# and VB.NET are provided. The importance and flexibility of these
as better programming languages is still questionable. Visual basic has been
updated and revised to make it object oriented whereas C# has concepts from
many languages such as Delphi, Java, etc and syntax from C and Java.
3. Write short notes on Data Types with example?
VB.NET sample :
Dim count As Integer
count : is the variable name
Integer : is the data type
Boolean , Integer and String are the Data types in VB .NET
4. What are the Control Statements involved in VB .NET?
IF ELSE and the Loops like For..NEXT , While..END WHILE are the Control
Statements.
Operator Operation
+ Addition
- Subtraction
Comparison Operators
Operator Operation
> Greater than
<= Less than or equal to
>= Greater than or equal to
Like Compares string to pattern
Is Tests to see if obj1 and obj2 refer
to same object
& Concatenation
+ String concatenation
And And
<> Inequality
< Less than
Or Or
Xor Xor
AddressOf Returns address of a given
procedure
GetType Returns the type of an object
Not Negative for booleans
A class is simply an abstract model used to define new data types. A class may
contain any combination of encapsulated data (fields or member variables),
operations that can be performed on the data (methods) and accessors to data
(properties).
Namespace Animals
Dog is a class in the namespace Animals
Class Dog
Bark is a function in this Class
Function Bark()
Console.Writeline ("Dog is barking")
End Function
End Class
End Namespace
9. What is objects in VB .NET?
Fields, Properties, Methods, and Events are members of the class. They can
be declared as Public, Private, Protected, Friend or Protected Friend.
Fields and Properties represent information that an object contains. Fields
of a class are like variables and they can be read or set directly. For example, if
you have an object named House, you can store the numbers of rooms in it in a
field named Rooms.
Public Class House
Public Rooms as Integer
End Class
11. How do you Create a Write-Only Property
A write-only property is one that defines a Set…End Set block and no Get…
End Get block. You are allowed to place data into this property only at run time,
but are unable to retrieve data from this property.
12. Program to explain Write-Only Property
Operator overloading is the ability for you to define procedures for a set of
operators on a given type. This allows you to write more intuitive and more
readable code.
16. What are the operators that can be overloaded?
Unary operators:
+ - Not IsTrue IsFalse CType
Binary operators:
+ - * / \ & Like Mod And Or Xor
^ << >> = <> > < >= <=
Interfaces define the properties, methods, and events that classes can
implement. Interfaces allow you to define features as small groups of closely
related properties, methods, and events; this reduces compatibility problems
because you can develop enhanced implementations for your interfaces without
jeopardizing existing code.
18. How will you create a interface?
Define your interface by adding code to it that begins with the Interface
keyword and the name of the interface, and ends with the End Interface
statement. For example, the following code defines an interface named
Encryption:
Interface Encryption
End Interface
19. Define Arrays in VB.NET with example
Arrays are using for store similar data types grouping as a single unit. We can
access Array elements by its numeric index.
Dim week(6) As String
20. Write a program to Swap elements in an array
Module Module1
Sub Main()
The FOR NEXT Loop , execute the loop body (the source code within
For ..Next code block) to a fixed number of times.
For var=[startValue] To [endValue] [Step]
[loopBody]
Next [var]
var : The counter for the loop to repeat the steps.
starValue : The starting value assign to counter variable .
endValue : When the counter variable reach end value the Loop will stop .
loopBody : The source code between loop body
28. Example for Functions?
Imports System.Console
Module Module1
Sub Main()
Write("Sum is" & " " & Add())
Variables declared within methods are called method variables. They have
method scope which means that once the method is executed they are destroyed
and their memory is reclaimed.
30. Why you want to only expose properties through a Property
statement?
UNIT IV
VB .NET
1. Structured versus Unstructured When to Use Which?
A Catch clause can take three possible forms: Catch, Catch...As, and
Catch...When.
A Catch clause with no When keyword allows the associated statement block to
handle any exception. Catch...As and Catch...When clauses catch a specific
exception and allow the associated statement block to tell the application what to
do. Catch...As and Catch...When clauses can also be combined in a single
statement, such as Catch ex As Exception When intResult <> 0. If the exception
is a result of resource failure, it should identify the resource and, if possible,
provide troubleshooting advice or workaround tips.
5. Write a example program for exceptional?
Imports System
Try
varAvailableSeats = varAuditoriumSeats - varNumberOfGuests
Catch ex As Exception When varAuditoriumSeats = 0
MsgBox("Auditorium lacks chairs!")
Exit Sub
Catch ex As Exception When varAvailableSeats < 0
MsgBox("There are no more available seats.")
Exit Sub
Finally MsgBox("Thank you for your interest in our concert.")
End Try
6. List out some of the useful properties of the Exception object
The HelpLink property can hold an URL that points the user to further
information about the exception.
The HResult property gets or sets HRESULT, a numerical value
assigned to the exception. HRESULT is a 32-bit value that contains
three fields: a severity code, a facility code, and an error code. The
severity code indicates whether the return value represents information,
a warning, or an error. The facility code identifies the area of the system
responsible for the exception. The error code is a unique number
assigned to represent the error.
The InnerException property returns an exception object representing
an exception that was already in the process of being handled when the
current exception was thrown. The code handling the outer exception
may be able to use the information from the inner exception in order to
handle the outer expression with greater precision.
The Message property holds a string, which is the text message that
informs the user of the nature of the error and the best way or ways to
address it. During the creation of an exception object, you can provide
the string best suited to that particular exception. If none is provided,
the default string will be provided and formatted according to the
current culture.
7. Example for Structured Exception Handling
This code example is a simple Try...Catch block that first checks for
ArithmeticException and then checks for generic exceptions.
Imports System
Sub Main()
Imports System
Public Class SamplesDelegate
' Declares a delegate for a method that takes in an int and returns a String.
Delegate Function myMethodDelegate(myInt As Integer) As [String]
' Defines some methods to which the delegate can point.
Public Class mySampleClass
' Defines an instance method.
Public Function myStringMethod(myInt As Integer) As [String]
If myInt > 0 Then
Return "positive"
End If
If myInt < 0 Then
Return "negative"
End If
Return "zero"
End Function 'myStringMethod
' Defines a static method.
Public Shared Function mySignMethod(myInt As Integer) As [String]
If myInt > 0 Then
Return "+"
End If
If myInt < 0 Then
Return "-"
End If
Return ""
End Function 'mySignMethod
End Class 'mySampleClass
Public Shared Sub Main()
' Creates one delegate for each method. For the instance method, an
' instance (mySC) must be supplied. For the Shared method, the
' method name is qualified by the class name.
Dim mySC As New mySampleClass()
ADO.NET is a set of classes that expose data access services to the .NET
programmer. ADO.NET provides a rich set of components for creating distributed,
data-sharing applications. It is an integral part of the .NET Framework, providing
access to relational data, XML, and application data. ADO.NET supports a variety
of development needs, including the creation of front-end database clients and
middle-tier business objects used by applications, tools, languages, or Internet
browsers.
12. Where are the ADO .NET Classes found?
The ADO.NET classes are found in System.Data.dll, and are integrated with
the XML classes found in System.Xml.dll. When compiling code that uses the
System.Data namespace, reference both System.Data.dll and System.Xml.dll.
13. Draw the ADO.NET Architecture
18. List the .NET Framework data providers that are included in the .NET
Framework?
UNIT V
J2EE
1. What is J2EE?
J2EE is an environment for developing and deploying enterprise
applications. The J2EE platform consists of a set of services, application
programming interfaces (APIs), and protocols that provide the functionality for
developing multitiered, web-based applications.
2. What are the components of J2EE application?
A J2EE component is a self-contained functional software unit that is
assembled into a J2EE application with its related classes and files and
communicates with other components. The J2EE specification defines the
following J2EE components:
Application clients and applets are client components.
Java Servlet and JavaServer Pages technology components are web
components.
Enterprise JavaBeans components (enterprise beans) are business
components.
Resource adapter components provided by EIS and tool vendors.
Highly Scalable
Simplified Architecture
Client tier: In the client tier, Web components, such as Servlets and
JavaServer Pages (JSPs), or standalone Java applications provide a
dynamic interface to the middle tier.
Middle tier: In the server tier, or middle tier, enterprise beans and Web
Services encapsulate reusable, distributable business logic for the
application. These server-tier components are contained on a J2EE
Application Server, which provides the platform for these components to
perform actions and store data.
Enterprise data tier: In the data tier, the enterprise's data is stored and
persisted, typically in a relational database.
27. what are the best practices to be carried out in development phase?
Use proven design patterns
Automate the build process
Integrate often
Optimize communication costs
28. what are the best practices to be carried out in deployment phase?
Use j2ee standard packaging specification
Use tools to help in deployment
Back up your production data and environment