Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 38

MANAKULA VINAYAGAR INSTITUTE OF TECHNOLOGY

Kalitheerthalkuppam, Puducherry – 605107.


DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
CS P73 PLATFORM TECHNOLOGY
ALL UNIT TWO MARKS QUESTIONS
UNIT 1
1. What is .NET?
The .NET Framework comprises:

• Common Language Runtime (CLR);

• .NET Framework Class Library;

• .NET languages including C#;

• Visual Studio.NET IDE.

.NET supports multiple languages making it suitable for cross‐


platform applications. All .NET languages must comply with the Common
Language Specification (CLS)—an agreement encompassing the specifications for
.NET languages. Microsoft offers four .NET languages—Visual Basic .NET,
Visual C#, Visual C++ with managed extensions, and Jscript.The CLR comprises
an execution engine, a garbage collector, a just‐in‐time (JIT) compiler, a security
system, and the .NET Framework fundamentals.
2. What is Application Framework?

A set of classes and‐or libraries used to implement the standard structure of


an application for a specific operating system is called as application
framework.They provide structure and services for application development.
Application frameworks are extensible, modular, and reusable.
3. What is NET Framework?

Microsoft programming infrastructure for creating, deploying, and


executing applications and services that use .NET technologies. .NET
Framework comprises three major components - Common Language Runtime
(CLR), Framework Base Classes and ASP.NET .

4. Explain with diagram the .NET Framework

CS T73 [PLATFORM TECHNOLOGY] Page 1


5. What is boxing?

Converting a value type to a reference type object is called boxing. A value


type is stored on stack memory and requires conversion—boxing—to an object on
the heap memory before it can be treated as an object. The members of 3 the
new object can be invoked on the value, e.g., converting a double to a
string. Boxing may be performed implicitly at runtime by the CLR.
int m = 10;
object om = m;
m = 20;
Console.WirteLine (m); // m = 20
Console.WriteLine (om); //om = 10
6. What is Unboxing?

Conversion of a reference typed object to the associated value type


instance. Usually, unboxing is performed explicitly by a cast operation.
int m = 10;
object om = m;
int n = (int) om;
7. Define Common Language Runtime (CLR)

CLR is the .NET runtime environment responsible for program


execution management and for providing container services—debugging,
exception management, memory management, profiling, and security. The
CLR is a major subsystem in the .NET Framework which implements the
Common Type System. Also this is called as Virtual Execution System (VES).
8. What are the services provided by the CLR?

• Loading and execution of programs.


• Memory isolation for applications.
• Verification of type safety
• Compilation of IL into native executable code
• Providing metadata
• Memory Management (automatic garbage collection)
• Enforcement of Security
• Interoperability with other systems.
• Managing exceptions and errors
• Support for tasks such as debugging and profiling.
9. What are the benefits of CLR?

• Interoperability with other languages


• Enhanced security
• Versioning support
• Debugging support
• Automatic garbage collection
• XML support for web‐based applications
10. List out the components of CLR

a) Common Type System


b) Intermediate Language (IL)
c) Execution Support Functions
d) Security
e) Garbage Collection
f) Class Loader
g) Memory Layout
11. Define Common Language Specification (CLS)

CS T73 [PLATFORM TECHNOLOGY] Page 2


CLS is a subset of the Common Type System and a set of
conventions for promoting interoperability between programming languages and
the .NET Framework. CLS details conventions that must be followed by class
library authors and by programming language designers.
12. Define Common Type System (CTS)

CTS is the .NET Framework specification for defining, declaring, and


managing types in .NET languages for the Common Language Runtime
(CLR). All .NET components must comply with the CTS specification.
13. What is Framework Class Library (FCL)?

FCL comprises the thousands of classes constituting the foundation of


the .NET Framework. FCL services include core functionality—collections, file and
network I/O, system service access, value types, etc.—, database interaction,
desktop‐based application support—Windows Forms—, Web‐based application
support—Web Forms—, Web services support, and XML support.
14. What is Just‐In‐Time (JIT)?

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?

Data in memory allocated and deallocated by the Common Language


Runtime (CLR). Managed data can be accessed only by managed code.
18. What is unmanaged data?
Data allocated outside of the control of the Common Language Runtime (CLR).
Unmanaged data is accessible by both managed and unmanaged code.
19. What is Microsoft Intermediate Language (MSIL)?

.NET language compilers—e.g., C# and VB.NET— compile source code


into MSIL—a machine‐ independent, intemediate language. MSIL is
subsequently compiled by the Just‐In‐Time (JIT) compiler into machine language
just prior to execution. The Native Image Generator Tool can also be used to
convert MSIL into machine language.
20. What is Abstract IL?

ILX is a toolkit for accessing the contents of .NET Common IL


binaries. Features include transforming binaries into structured abstract syntax
trees to be manipulated.
21. Define Virtual Execution System (VES)?

CS T73 [PLATFORM TECHNOLOGY] Page 3


VES is the environment for executing managed code. VES defines a
virtual machine. Thus, VES supports execution of the Common Intermediate
Language instruction set. Also, VES provides support for built‐in data types, a set
of control flow constructs, and a model for exception handling.
22. What are the components included in the .NET platform?
 .NET infrastructure and tools
 .NET user experience
 .NET building block
 .NET device software
23. Write a short note on OLE technology.

OLE (Object Linking and Embedding) technology was developed by


Microsoft in the early 1990s to enable easy interprocess communications. OLE
provided support to achieve the following:
To embed documents from one application into another application.
To enable one application to manipulate objects located in another
application.
Ex: interoperability between MS‐Excel and MS‐Word
24. What are Web Services used for?

Uses of Web Services:


 Middleware for distributed applications
 For remote procedure calls and data exchange
 Open standard based on XML
 For loosely coupled software services
 Independent of programming languages and operating systems
 Utilizing existing Internet protocols and server architectures
25. What .Net Provides for Web Services?

Web Services in .NET


•IIS and ASP.NET infrastructure support web services
•.NET Framework provides several base classes, attributes, protocols for the
realization of web services
•Visual Studio.NET provides powerful tools for developing web services
implementation testing administration of IIS generation of proxy code (wsdl.exe)
26. Write down some of the namespaces available in the .NET framework?

 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?

 Complete object-oriented design.

CS T73 [PLATFORM TECHNOLOGY] Page 4


 A good blend of Visual Basic simplicity and C++ power.

 Garbage collection.

 Syntax and keywords similar to C and C++.

 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.

28. Explain about the type variables

29.Explain with neat diagram components CLR

30. Write about JIT compiler?

Just - in - Time (JIT) compiler, which compiles MSIL into native code that is
specific to the OS and machine architecture being targeted.

31. Explain the managed code execution process?

CS T73 [PLATFORM TECHNOLOGY] Page 5


30. Explain the unmanaged code execution process?

32. What is serialization?

Serialization can be defined as the process of storing the state of an object


instance to a storage medium. During this process, the public and private fields of
the object and the name of the class, including the assembly containing the class,
is converted to a stream of bytes, which is then written to a data stream. When
the object is subsequently deserialized, an exact clone of the original object is
created.
33. What is remoting?

CS T73 [PLATFORM TECHNOLOGY] Page 6


Remoting provides a framework that allows objects to interact with one
another across application domains. The framework provides a number of
services, including activation and lifetime support, as well as communication
channels responsible for transporting messages to and from remote applications.

34. Explain diagrammatically the interoperability function using COM?

UNIT II
.NET Languages
1. What Is C#?

C# (pronounced as 'c’ sharp') is a new computer‐programming language


developed by Microsoft Corporation, USA. C# is a fully object‐oriented language
like Java and is the first Component‐oriented language. It has been designed to
support the key features of .NET Framework, the new development platform
of Microsoft for building component‐based software solutions. It is a simple,
efficient, productive and type‐safe language derived from the popular C and
C++ languages. Although it belongs to the family of C / C++, it is a purely
objected‐oriented, modem language suitable for developing Web based
applications.
2. What is Characteristic of C#?
 Simple
 Consistent
 Modern
 Object - Oriented
 Type - Safe
 Versionable
 Compatible
 Interoperable
 Flexible
3. What are the APPLICATIONS OF C#?
 . Console applications
 . Windows applications
 . Developing Windows controls
 . Developing ASP.NET projects
 . Creating Web controls
 . Providing Web services
 . Developing .NET component library

4. List out the features of C++, which are dropped in C#?

The following features of C++ are missing in C#:


 Macros
 Multiple Inheritance

CS T73 [PLATFORM TECHNOLOGY] Page 7


 Templates
 Pointers
 Global Variables
 typedef statement
 Default arguments
 Constant member functions or parameters
 Forward declaration of classes.
5. What are the enhancements done to C++ in C# environment?

C# modernizes C++ by adding the following new features:


 Automatic Garbage Collection
 Versioning support
 Strict type‐safety.
 Properties to access data members
 Delegates and events
 Boxing and unboxing
 Web Services.
6. List out the two types C# programs?

C# can be used to develop two categories of programs, they are,


a) Executable application programs (.exe)
b) Component Libraries (.dll)
7. What are the major highlights of C#?

• It simplifies and modernizes C++


• It is the only component‐oriented language available today.
• It is the only language designed for the .NET Framework
• It combines the best features of many commonly used languages: the
productivity of visual basic, the power of C++ and the elegance of Java
• It is intrinsically object‐oriented and web‐enabled.
• It has a lean and consistent syntax.
8. List out some problems of C and C++

• They have long cycle‐time.


• They are not truly object‐oriented.
• They are not suitable for working with new web technologies.
• The have poor type‐safety.
• They are prone to costly programming errors.
• They do not support versioning.
• They are prone to memory leakages.
• They are weak in consistency
9. What is the limitation of Visual Basic?

Since Visual Basic is not truly an object‐oriented programming language, it


becomes increasingly difficult to use when systems become large.
10. What are the limitations of using Java language?

• 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?

C# borrows Java’s features such as grouping of classes, interfaces and


implementation together in one file so that programmers can edit the code more
easily. C# also handles objects using references, the same way as Java. C#

CS T73 [PLATFORM TECHNOLOGY] Page 8


borrows VB’s approach to form design, namely, dragging controls from a tool box,
dropping them onto forms, and writing event handlers for them.
12. What is Command Line Argument?

There may be occasions when we may like our program to behave in a


particular way depending on it input provided at the time of execution. This
is achieved in C# by using what are known as command line arguments.
Command line arguments are parameters supplied to the Main method at the
time of invoking it for execution.
13. What is comment? List out its types?

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# program contains following sections in it:


a) Documentation Section
b) Using Directive Section
c) Interfaces Section
d) Classes Section
e) Main Method Section
15. C# is a freeform language. Comment

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#?

C# has five types of tokens. They are,


a) Keywords
b) Identifiers
c) Literals
d) Operators
e) Punctuators
17. What are keywords?

Keywords are an essential part of a language definition. They implement


specific features of the language. They are reserved, and cannot be used as
identifiers except when they are prefaced by the @ character. There are 79
keywords in C#. Ex: public, private, if, while etc..
18. What are identifiers?

CS T73 [PLATFORM TECHNOLOGY] Page 9


Identifiers are programmer‐designed tokens. They are used for naming
classes, methods, variables, labels, namespaces, interfaces, etc. C# identifiers
enforce the following rules:
They can have alphabets, digits and underscore characters. They must not begin
with a digit
Upper case and lower case letters are distinct
Keywords in stand‐alone mode cannot be used as identifiers
C# permits the use of keywords as identifiers when they are prefixed with a ‘@’
character.
19. What are the lexical elements of C#?

1. Comments
2. white spaces
3. tokens
4. preprocessing directives
20. What is line terminator in C#?

A new line character is known as line terminator in C#. The


following characters are treated as line terminators:
• The carriage return character (U+000D)
• The line feed character (U+000A)
• The carriage return character followed by a line feed character.
• The line separator character (U+2028)
• The paragraph separator character (U+2029)
21. What are punctuators?

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?

Stack - Represents a portion of memory that can be used by the program at


runtime. This memory is not subject to garbage collection. The lifetime of the
variables stored in stack is limited to the lifetime of the block in which it is
defined. Method states are allocated on stack. Thus, local variables,
arguments of methods, and local object references are allocated on stack
memory.
Heap - This is the region of memory used for dynamic storage. It is reserved for
a program to use for the temporary storage of data structures whose existence or
size cannot be determined until the program is running. It is subjected to
garbage collection. The problem of memory leak is avoided in this type of
memory allocation.
23. What is value type?

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?

CS T73 [PLATFORM TECHNOLOGY] Page 10


It includes class types, interface types, delegate types and array types.
Reference variable stores references to objects whereas the data of objects
are stored in locations represented by references. Reference variable points to
an object allocated on heap. Reference variable can have null value. One or more
reference variables can be assigned with the same reference of an object. Hence,
operation on one reference variable may affect the object referenced by the
other reference variable.
25. What are statements?

Statements in C# are like sentences in natural languages. A statement


is an executable combination of tokens ending with a semicolon. C#
implements several types of statements. They include:
Empty Statements
Labeled statements
Declaration statements
Expression statements
Selection statements
Interaction statements
Jump statements
The try statements
The checked statements
The unchecked statements
The lock statements
The using statements
26. What are escape sequences?

C# supports special backslash character constants that are used in


output methods. These character combinations are called as escape sequences.
Some escape sequences are:
\n new line
\t horizontal tab
\f form feed
\r carriage return
\b backspace
27. What is NaN?

Floating‐point data types support a special value known as Not‐a‐


Number (NaN). NaN is used to represent the result of operations such as
dividing zero by zero, where an actual number is number is not produced. Most
operations that have NaN as an operand will produce NaN as a result.
28. List out reference data types?

The reference types can also be divided into two groups:


User‐defined (or complex) types
Predefined (or simple) types
User‐defined reference types refer to those which are defined by the user
using predefined type. They include,
Classes
Interfaces
Delegates
Arrays
Predefined reference types include two data types:
Object type
String type
29. Which types of variables are initialized with default value?

CS T73 [PLATFORM TECHNOLOGY] Page 11


The following categories of variables are automatically initialized to their
default values.
Static variables
Instance variables
Array elements
30. What is the default value for built‐in data types?

All integer type 0


char type ‘\x000’
float type 0.0f
double type 0.0d
decimal type 0.0m
bool type false
enum type 0
All reference types null
31. How constants are created in C#?

The constants can be created by using any one of the method:


using const keyword
Ex:const int ROW = 10;
const float PI = 3.14;
using #define statement (symbolic constants)
Ex:#define ROW 10
#define PI 3.14
32. What are the advantages of using constants?

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.

C# operators can be classified into a number of related categories as below:


 Arithmetic operators
 Relational operators
 Logical operators
 Assignment operators
 Increment and decrement operators
 f)Conditional operators
 Bitwise operators
 Special operators
34. What are special operators available in C#?

C# supports the following special operators:


is (relational operator)
as (relational operator)
typeof (type operator)
sizeof (size operator)
new (object operator)
.(dot) (member‐access operator)
checked (overflow checking)
unchecked (prevention of overflow checking)
35. What is the advantage of using foreach loop?

The advantage of foreach over for statement is that it automatically


detects the boundaries of the collection being iterated over. Further, the
syntax includes a built‐in iterator for accessing the current element in the
collection.

CS T73 [PLATFORM TECHNOLOGY] Page 12


36. What are types of parameters available?

C# employs four kinds of parameters:


 Value parameters - used to pass the parameters by value
 Reference parameters - used to pass the parameters by reference
 Output parameters - used to pass the results back from a method
 Parameter arrays (using param) - used to pass a variable number of
parameters
37. Write a short note on pass by value.

By default, method parameters are passed by value. When a method


is invoked, the values of actual parameters are assigned to the corresponding
formal parameters. The value of the actual parameter that is passed by value
to a method is not changed by any changes made to the corresponding
formal parameter within in the body of the method.
Ex:
using System;
class PassByValue
{
static int increment(int val)
{
return ++val;
}
public static void Main()
{
int a = 10;
Console.WriteLine(“Value of a ‐ before calling increment is “ + a);
Console.WriteLine(“Value returned by increment is “ + increment(a);
Console.WriteLine(‘Value of a - after calling increment is {0}”, a); }
}
Output:
Value of a - before calling increment is 10
Value returned by increment is 11
Value of a - after calling increment is 10
38. Write a short note on pass by reference.

Unlike a value parameter, a reference parameter does not create a new


storage location. Instead, it represents the same storage location as the actual
parameter used in the method invocation. Remember, when a formal parameter is
declared as ref, the corresponding argument in the method invocation must also
be declared as ref.
Ex:
using System;
class PassByRef
{
static void increment(ref int val)
{
++val;
}
public static void Main()
{
int a = 10;
Console.WriteLine(“Value of a ‐ before calling increment is “ + a); increment( ref a);
Console.WriteLine(‘Value of a - after calling increment is {0}”, a);
}
}

CS T73 [PLATFORM TECHNOLOGY] Page 13


Output:
Value of a - before calling increment is 10
Value of a - after calling increment is 11
39. Write a short note on output parameters.

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

In C#, the methods can be defined to handle variable number of


arguments using what are known as parameter arrays. Parameter arrays are
declared using the keyword params. This can be combined with the formal
parameter list and in such cases, it must be the last parameter. It is permitted to
use parameter arrays along with the value parameters, but it is not allowed to
combine the params modifier with the ref and out modifiers.
Ex:
using System;
class ParamsTest
{
static int sum(params int[] val)
{
int tot=0;
foreach (int i in val)
tot = tot + i;
return tot;
}
public static void Main()
{
Console.WriteLine(“The sum of 40,50,60 is {0}”, sum(40,50,60));
Console.WriteLine(“The sum of 2,3,12,15,17 is {0}”, sum(2,3,12,15,17));
Console.WriteLine(“The sum of 12 is {0}”, sum(12));
}
}
Output:
The sum of 40,50,60 is 150
The sum of 2,3,12,15,17 is 49 The sum of 12 is 12

CS T73 [PLATFORM TECHNOLOGY] Page 14


41. How the compiler selects a method for compilation?

The method selection involves following steps:


1. The compiler tries to find an exact match in which the types of actual
parameters are the same and uses that method.
2. If the exact match is not found, then the compiler tries to use the implicit
conversions to the actual arguments and then uses the method whose
match is unique. If the conversion creates multiple matches, then the compiler
will generate an error message.
42. Can a method return more than one value in C#? Justify your answer.

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?

A class is essentially a description of how to construct an object that


contains fields and methods. It provides a sort of template for an object and
behaves like a basic data type such as int. Classes provide a convenient approach
for packing together a group of logically related data items and functions that
work on them.

44. Write a note on encapsulation?

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?

CS T73 [PLATFORM TECHNOLOGY] Page 15


Polymorphism is the ability to take more than one form. The behavior of the
method depends upon the types of data used in the operation. This is extensively
used while implementing inheritance.

47. What is the Characteristic of Inheritance?

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

1. Reuse the existing code and extend the functionality.


2. Add new members to the derived class to specialize the class.
3. replace the implementation of existing methods by overriding a method that
already exists in the base class. use of virtual and override methods help to
exhibit polymorphic behavior.
4. Organize software components into categories and subcategories
resulting in classification of software. Classification is the most widely
accepted use of inheritance although other mechanisms may also be used for
classification.
49. List out the member access modifiers in C#

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 constructor is the same as the class.


A constructor does not return any value and hence does not have a return
type. The formal parameters define the signature of the constructor. A
constructor initializer cannot access the object being created. A constructor is
called when an object is created.
51. What is default constructor?

A public parameterless constructor is called default constructor. And it is


implicitly declared for any class. Even though there is no constructor in the class
this default constructor will be invoked and initializes the member with default
value of that type.
Simply, the process called instantiation is done through calling the constructor
only.
52. What is the use of private constructors?

C# does not have global variables or constants. All declarations must


be contained in a class. But using static members this can be achieved
some what. Such classes are never required to instantiate objects because;
object is not needed to access the static members of a class. Creating

CS T73 [PLATFORM TECHNOLOGY] Page 16


objects for such classes may be prevented by using private constructor to the
class.

53. What is copy constructor?

A copy constructor creates an object by copying variables from


another object. But there is no copy constructor provided in C#. It should be
defined by the programmer.
Ex: public Point(Point pt)
{ x = pt.x;
y = pt.y;
}
The copy constructor is invoked when instantiating the object of type Point. For
example,
Point p2 = new Point(p1);
54. What is destructor?

A destructor is opposite to a constructor. It is a method called when an


object is no more required. The name of the destructor is the same as the class
name and is preceded by a tilde (~). Like constructors, a destructor has no return
type.
55. What are the features of a destructor?

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.

CS T73 [PLATFORM TECHNOLOGY] Page 17


The static modifier can be used to declare properties that belong to the
whole class rather than to a specific instance of the class.
58. What are indexers?

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
}
}

59. Differentiate indexer from property.

A property can be static member, whereas an indexer is always an instance


member A get acccessor of a property corresponds to a method with no
parameters, whereas a get accessor of an indexer corresponds to a method
with the same formal parameter list as the indexer.
A set accessor of a property corresponds to a method with a single
parameter named value, whereas a set accessor of an indexer corresponds to a
method with the same formal parameter list as the indexer, plus the parameter
named value. It is an error for an indexer to declare a local variable with
the same name as an indexer parameter. The indexer takes an index argument
and looks like array. The indexer is declared using the name this.
60. What is the containment inheritance?

If an object contains another object in it, it is called as containment


inheritance. This represents the “has‐ a” relationship.
Ex:
class A
{
int a;
}
class B
{
int b;
A aa; // object aa is contained in object of B
….
}
61. What are the constraints on the accessibility of members and classes
in C#?

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?

CS T73 [PLATFORM TECHNOLOGY] Page 18


1. An override declaration may include the abstract modifier.
2. It is an error for an override declaration to include new or static or virtual
modifier.
3. The overridden base method cannot be static or nonvirtual.
4. The overridden base method cannot be a sealed method. What is the use of
abstract modifier with class?
The abstract is a modifier and when used to declare a class indicates that
the class cannot be instantiated. Only its derived classes can be instantiated. So,
the object can’t be created for an abstract class.

63. What is Regular expression?

A regular expression—also called regex, regexes, regexp, regexps, and


regexen—is a string that describes a set of strings to be found or altered according
to certain syntax rules. The regular expression pattern matching process is
supported by programming languages, text editors, and utilities. A regular
expression may include alphanumeric characters, metacharacters, and operators.
Most .NET languages— including Visual C#—support regular expressions.
64. What is polymorphism? What are the methods available to do that?

Polymorphism means “one name, many forms”. Essentially, polymorphism


is the capability of one object to behave in multiple ways. It can be achieved in
two ways:
1. Operation Polymorphism can be achieved by using overloaded methods.
2. Inclusion Polymorphism can be achieved by using virtual methods.
65. What is operation polymorphism?

Operation polymorphism is implemented using overloaded methods


and operators. The overloaded methods are selected for invoking by
matching arguments, in terms of number, type and order. This information
is known to the compiler at the time of compilation and, therefore, the
compiler is able to select and bind the appropriate method to the object
for a particular call at compile time itself. This process is called early
binding, or static binding, or static linking. It is also known as compile
time polymorphism.
66. Write a note on interface.

An interface can contain one or more methods, properties, indexers,


and events but none of them are implemented in the interface itself. It is
the responsibility of the class that implements the interface to define the
code for implementation of these members.
Syntax:
interface InterfaceName
{
Member declarations;
}
67. What are the operators which can be overloaded?

Binary arithmetic operators +*/‐%


Unary arithmetic operators + ‐ ++ ‐‐
Binary bitwise operators & | ^ << >>
Unary bitwise operators ~ ! true false
Relational operators == != <= >= > <
68. What are the operators which can’t be overloaded?

Logical operators && ||


Compound assignment operators += ‐= *= /= %=

CS T73 [PLATFORM TECHNOLOGY] Page 19


Other operators [] () = ?: ‐> new sizeof typeof is as
69. What are limitations of operator overloading?

1. When we overload a binary operator, its compound assignment


equivalent is implicitly overloaded.
2. Relational operators must be overloaded in pairs, i.e == and != must be done
together.
3. Operators that are currently not defined in C# cannot be overloaded.
4. We cannot change the syntax, the grammatical rules that govern its use such
as the number of
operands, precedence and associativity.

70. What is need for operator overloading?

1. Mathematical or physical modeling needs classes to represent objects


such as coordinates, vectors, matrices, tensors, complex numbers and so on.
2. Graphical programs where co‐ordinate related objects are used to
represent positions on the screen.
3. Financial programs where a class represents an amount of money.
4. Text manipulations where classes are used to represent strings and
sentences.
71. What are the key features of Operator Overloading?

1. They must be defined as public and static


2. The retval (return value) type is the type that we get when we use
this operator. But, technically, it can be of any type.
3. The arglist is the list of arguments passed. The number of arguments
will be one for the unary operators and two for the binary operators.
4. In the case of unary operators, the argument must be the same type as that of
the enclosing class or struct.
5. In the case of binary operators, the first argument must be of the same type
as that of the enclosing class or struct and the second may be of any type.
72. Define Delegate?

It is an Event handling mechanism of .NET. To raise events, a class must


define one delegate per event type. To handle events, types must implement
one event handler per event type. Delegates can reference both instance and
static methods. C# uses the delegate keyword.
73. What are steps involved in using delegates in a C# program?

1. Delegate declaration
2. Delegate methods definition
3. Delegate instantiation
4. Delegate invocation
74. Write a note on delegates.

Delegate is a method which is acting for another method. A delegate


declaration defines a class using the class System.Delegate as a base class.
Delegate methods are any functions whose signature matches the delegate
signature exactly. The delegate instance holds the reference to delegate methods.
The instance is used to invoke the methods indirectly. An important feature of
delegate is that it can be used to hold reference to a method of any class. The
basic requirement is that its signature must match the signature of the method.

75. What is an event?

CS T73 [PLATFORM TECHNOLOGY] Page 20


An event is a delegate type class member that is used by the object or class
to provide a notification to other objects that an event has occurred. The
client object can act on an event by adding an event handler to an event.
The type of an event declaration must be a delegate type and the delegate
must be as accessible as the event itself.
76. What is the differ0ence between Read() and ReadLine()?

Read( ) - Returns a single character as int. Returns ‐1 if no more characters are


available.
ReadLine() - Returns a string containing a line of text. Returns null if no more
lines are available.
77. What is an error?

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.

1. Dividing an integer by zero


2. Accessing an element that is out of bounds of an array
3. Trying to store a value into an array of an incompatible class or type
4. passing a parameter that is not in a valid range or value for a method
5. Attempting to use a negative size for an array.
79. What is Exception?

When an unplanned or unexpected event occurs, an associated exception


object is thrown. The exception will be caught by an exception handler at
some level and appropriate action taken. A fatal exception—catastrophic
error—is an event that cannot be properly handled to allow the application
to continue.
80. What is Exception handling?

Process of intercepting—trapping—an exception and acting appropriately in


response.

81. What are tasks involved in exception handling?

1. Find the problem (Hit the exception)


2. Inform that an error has occurred (Throw the exception)
3. Receive the error information (Catch the exception)
4. Take corrective actions (Handle the exception)
82. Differentiate Property and Indexer

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?

Supercede an instance field or virtual method in a base class with a


new definition of that member in the derived class (subclass).

CS T73 [PLATFORM TECHNOLOGY] Page 21


UNIT III
VB .NET
1. Describe about Visual basic.NET?

This is used in conjunction with Microsoft .NET platform and is a successor to


visual basic sixth version. Visual basic is used in conjunction with.NET
Framework. This tool has a serious defect it is not compatible with Microsoft
visual basic sixth version. It has a huge library which assists programmers.
2. Compare between VB.Net and C#s

.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?

DATATYPE in a programming language describes that what type of data a


variable can hold . When we declare a variable, we have to tell the compiler about
what type of the data the variable can hold or which data type the variable
belongs to.
Syntax : Dim VariableName as DataType
VariableName : the variable we declare for hold the values.
DataType : The type of data that the variable can hold

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.

5. Write a Simple program to explain the FOR EACH loop in VB.NET

Private Sub Button1_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button1.Click
Dim siteName As String
Dim singleChar As Char
siteName = "HTTP://NET-INFORMATIONS.COM"
For Each singleChar In siteName
MsgBox(singleChar)
Next
End Sub
End Class
6. Write about the arithmetic and assignment operators in VB .NET

Arithmetic and Assignment Operators

Operator Operation
+ Addition
- Subtraction

CS T73 [PLATFORM TECHNOLOGY] Page 22


* Multiplication
/ Floating – point division
\ Integer division
^ Exponentiation
Mod Modulo division
= Equality
^= Exponentiation assignment
+= Addition assignment
*= Multiplication assignment
-= Subtraction assignment
/= Floating –point division
assignment
\= Integer division assignment
&= Concatenation and
assignment

7. Write about the Comparison operators in VB .NET

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

8. Define class in VB.NET?

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?

CS T73 [PLATFORM TECHNOLOGY] Page 23


A Method is a procedure built into the class. They are a series of statements
that are executed when called. Methods allow us to handle code in a simple and
organized fashion. There are two types of methods in VB .NET: those that return a
value (Functions) and those that do not return a value (Sub Procedures).
10. How are the Fields, Properties, Methods, and Events related to class?

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

WriteOnly Property FileName() As String


Set(ByVal Value As String)
mstrFileName = Value
End Set
End Property
13. Short notes on Inheritance in VB .NET?
 VB.Net, like C#, Java and contrary to C++, allows only single class
inheritance. Multiple inheritance of classes is not allowed in VB.Net
 The Object class defined in the System namespace is implicitly the
ultimate base class of all the classes in VB.Net (and the .Net framework)
 Interfaces, in VB.Net, can inherit more than one interface. So, multiple
inheritance of interfaces is allowed in VB.Net (again similar to C# and
Java). We will see interfaces in detail in the coming lessons
 Structures in VB.Net, can only inherit (or implement) interfaces and can
not be inherited.
14. Briefly explain the inheritance?

VB.Net uses the Inherits keyword to indicate inheritance. Suppose we have a


class named Student with the following fields; mRegistrationNumber, mName and
mDateOfBirth along with the corresponding properties. The class also has a
function called GetAge() which calculates and returns the age of a Student.

15. Write about operator Overloading

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
^ << >> = <> > < >= <=

CS T73 [PLATFORM TECHNOLOGY] Page 24


17. What is Interfaces in VB .NET?

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

Public Class Tester


Public Shared Sub Main
Dim result As New System.Text.StringBuilder
Dim arraySwap() As String = {"A", "B", "C", "D", "E"}
Swap(arraySwap, 1, 3)
For Each fruit As String In arraySwap
Console.WriteLine(fruit)
Next fruit
End Sub
Public Shared Sub Swap(ByRef swapArray() As Object, _
ByVal first As Integer, ByVal second As Integer)
Dim tempObject As Object
tempObject = swapArray(first)
swapArray(first) = swapArray(second)
swapArray(second) = tempObject
End Sub
End Class
21. Write a program for Substring
Module Module1
Sub Main()
' The string you are searching
Dim s As String = "Visual Basic rocks"
' Find index of uppercase letter 'B'
Dim i As Integer = s.IndexOf("B"c)
' This new string contains the substring starting at B
Dim part As String = s.Substring(i)
Console.WriteLine(part)
Console.ReadLine()
End Sub
End Module
22. Write a program for IndexOf?

Module Module1
Sub Main()

CS T73 [PLATFORM TECHNOLOGY] Page 25


' The input string you are using
Dim s As String = "Darth Vader has pulmonary problems."
' Does the string contain "Vader"?
If (s.IndexOf("Vader") <> -1) Then
Console.Write("string contains 'Vader'")
End If
' Finished
Console.ReadLine()
End Sub
End Module
23. What are strings in VB .NET?
The String data type comes from the System.String class . The String type
represents a string of Unicode Characters . The String class is a sealed class , so
you cannot inherit another class from the String class.
24. How are the Regular Expressions written in VB .NET?

The regex classes are located in the namespace


System.Text.RegularExpressions. To make them available, place Imports
System.Text.RegularExpressions at the start of your source code.

25. Write a Program for Every word replaced by another word


Imports System.Text.RegularExpressions
Public Class Tester
Public Shared Sub Main
Console.WriteLine(Regex.Replace("This sentence ends in 5 stars *****", "\w+",
"word"))
End Sub
End Class
Implicit and Explicit Conversions
26. What are the Implicit Type Conversions?

Implicit Conversion perform automatically in VB.NET, that is the compiler


is taking care of the conversion.The following example.
 Dim iDbl As Double
 Dim iInt As Integer
 iDbl = 9.123
 MsgBox("The value of iDbl is " iDbl)
 iInt = iDbl
 MsgBox("The value of iInt is " iInt)
27. Write about FOR NEXT Loop

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())

CS T73 [PLATFORM TECHNOLOGY] Page 26


'calling the function
End Sub
Public Function Add() As Integer
'declaring a function add
Dim i, j As Integer
'declaring two integers and assigning values to them
i = 10
j = 20
Return (i + j)
'performing the sum of two integers and returning it's value
End Function
End Module
29. What are the method variable?

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?

•We can create a read-only or write-only property, as opposed to a Public variable,


which will always be read-write.
•We can add error handling within a Property statement to check for invalid
values being set. We can't check for invalid values when setting a Public variable
because there is no code that runs in response to setting a Public variable.
•We can expose calculated values as properties even if they are not stored as
actual data within the class. An example of this is a Length property. We probably
don't want to store the length of a line of text, as it could change.

UNIT IV
VB .NET
1. Structured versus Unstructured When to Use Which?

Structured exception handling is simply that — using a control structure


containing exceptions, isolated blocks of code, and filters to create an exception
handling mechanism. This allows your code to differentiate between different
types of errors and react in accordance with circumstances. In unstructured
exception handling, an On Error statement at the beginning of the code handles
all exceptions.
2. When does the Unstructured suits?
 We are upgrading an application written in an earlier version of Visual
Basic.
 We are developing a preliminary or draft version of an application and
you don't mind if the program fails to shut down gracefully.
 We know in advance exactly what will cause the exception.
 A deadline is pressing and you need to take shortcuts.
 Code is trivial or so short that you only need to test the branch of code
generating the exception.
 We need to use the Resume Next statement, which is not supported in
structured exception handling.
 we cannot combine structured and unstructured exception handling in
the same function. If we use an On Error statement, you cannot use a
Try...Catch statement in the same function.
3. Write about Structured exception handling?

CS T73 [PLATFORM TECHNOLOGY] Page 27


Structured exception handling tests specific pieces of the code and, as
exceptions occur, adapts your exception-handling code to the circumstances that
caused the exception. It is significantly faster in large applications than
unstructured exception handling and allows more flexible response to errors as
well as greater application reliability.
4. What a Catch Clause Does

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()

CS T73 [PLATFORM TECHNOLOGY] Page 28


Dim x As Integer = 0
Try
Dim y As Integer = 100 / x
Catch ex As ArithmeticException
MessageBox.Show(ex.Message)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub 'Main
8. What is an Event?

An event is a message sent by an object to signal the occurrence of an


action. The action could be caused by user interaction, such as a mouse click, or
it could be triggered by some other program logic. The object that raises the event
is called the event sender. The object that captures the event and responds to it is
called the event receiver.
9. What is a delegate?

A delegate is a class that can hold a reference to a method. Unlike other


classes, a delegate class has a signature, and it can hold references only to
methods that match its signature. A delegate is thus equivalent to a type-safe
function pointer or a callback.
10. Write a Delegate program

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()

CS T73 [PLATFORM TECHNOLOGY] Page 29


Dim myD1 As New myMethodDelegate(AddressOf mySC.myStringMethod)
Dim myD2 As New myMethodDelegate(AddressOf
mySampleClass.mySignMethod)
' Invokes the delegates.
Console.WriteLine("{0} is {1}; use the sign ""{2}"".", 5, myD1(5), myD2(5))
Console.WriteLine("{0} is {1}; use the sign ""{2}"".", - 3, myD1(- 3), myD2(- 3))
Console.WriteLine("{0} is {1}; use the sign ""{2}"".", 0, myD1(0), myD2(0))
End Sub 'Main
End Class 'SamplesDelegate
11. What is ADO .Net?

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

14. What are the Uses of a DataSet?


 Remote data between tiers or from an XML Web service.
 Interact with data dynamically such as binding to a Windows Forms
control or combining and relating data from multiple sources.
 Cache data locally in your application.
 Provide a hierarchical XML view of relational data and use tools like an XSL
Transformation or an XML Path Language (XPath) Query on your data. For
more information, see XML and the DataSet.
 Perform extensive processing on data without requiring an open connection
to the data source, which frees the connection to be used by other clients.
15. How do you compile and run the ADO.NET sample application?

CS T73 [PLATFORM TECHNOLOGY] Page 30


1. Using Notepad or another text editor, create a blank text file named
sample.vb for Visual Basic sample code or named sample.cs for C# sample
code.
2. Copy and paste the Visual Basic or C# sample code from this topic into the
blank text file. Save the file.
3. Open a command prompt (Start, then Run, then enter "command").
4. In the command prompt, change the directory to the directory that
contains the new text file. For example:
cd\SampleCode\ADONETSample
5. In the command prompt, enter one of the following commands to compile
the sample (the path to your file will likely differ).
6. For Visual Basic, use vbc.exe and use the following command to reference
the system libraries needed to run your ADO.NET application.
vbc.exe sample.vb /r:System.dll /r:System.Data.dll
/r:System.Data.OracleClient.dll /r:System.Xml.dll
16. What are .NET Data Providers ?
A data provider in the .NET Framework serves as a bridge between an
application and a data source. A data provider is used to retrieve data from a data
source and to reconcile changes to that data back to the data source.
17. Explain with diagram .NET Data Providers

18. List the .NET Framework data providers that are included in the .NET
Framework?

CS T73 [PLATFORM TECHNOLOGY] Page 31


19. What are the Core elements of NET Framework data provider model.
The Connection, Command, DataReader, and DataAdapter objects
represent the core elements of the .NET Framework data provider model.

20. Explain about the classes in data provider model?

21. What is ADO.NET Dataset


The ADO.NET DataSet contains DataTableCollection and their
DataRelationCollection . It represents a collection of data retrieved from the Data
Source. We can use Dataset in combination with DataAdapter class. The DataSet
object offers a disconnected data source architecture. The Dataset can work with
the data it contain, without knowing the source of the data coming from. That is ,
the Dataset can work with a disconnected mode from its Data Source . It gives a

CS T73 [PLATFORM TECHNOLOGY] Page 32


better advantage over DataReader , because the DataReader is working only with
the connection oriented Data Sources.
22. Explain with a diagram the ADO.NET Dataset

23. How will you fill a DataSet using a TableAdapter


1. Create a new project in Visual Basic IDE.
2. On the Database Explorer click the icon for creating new data connection
and
3. Choose the SQL Server file.
4. Establish the connection and you should be seeing the database objects on
the window.
5. In the solution Explorer click on the project name and
6. Choose add an item option.
7. In the dialog box that opens choose DataSet item and
8. Name it as ds and click ok.
9. You will see the DataSet item added to the solution and also
10. A blank screen will be seen.
11. From the Database explorer drag and drop the table ProductCategory.
12. Choose ‘not’ in the message box that asks your permission to add the
datafile as a project data.
13. Now right click on the Form1 and
14. Choose the option to see the code window.
15. Type the following codes to fill the DataSet
Dim ProductCategoryTableAdapter As New
dsTableAdapters.ProductCategoryTableAdapter()
Dim ProductCategoryDataSet As New ds
ProductCategoryTableAdapter.Fill(ProductCategoryDataSet.ProductCategory)
24. How will you fill a DataSet by using a SqlDataAdapter?
1. Create a SqlConnection object. SqlDatAdapter object.
2. The SqlConnection object needs connection string as an argument and the
SqlDataAdapter requires the SQL Statement and Connection Object as an
argument.
3. The ConnectString gives details about the Database Server, Initial
Catalogue, connection type, userid and password.
4. A typical connection string could look like this:

CS T73 [PLATFORM TECHNOLOGY] Page 33


"data source=sql.domain.no; initial catalog=xxxxx; User ID=xxxxx;pwd=xxxxx;
Integrated Security=SSPI”
Code for filling the DataSet is given below:
Dim SQLStr As String
Dim ConStr As String
SQLStr = "SELECT Name FROM production.ProductCategory"
ConStr = "data source=sql.domain.no; initial catalog=xxxxx; User
ID=xxxxx;pwd=xxxxx; Integrated Security=SSPI"
Dim sqlConn As New System.Data.SqlClient.SqlConnection(ConStr)
Dim ds As New DataSet
Dim SQLAdapter As New System.Data.SqlClient.SqlDataAdapter(SQLStr,
ConStr)
SQLAdapter.Fill(ds)
25. Write a simple program to display data in a dataset in a grid?
Imports system.Data
Public Class Form1
Dim ProductDataSet As ds
Private Sub DataLoad()
Dim ProductTableAdapter As New dsTableAdapters.ProductTableAdapter()
ProductDataSet = New ds
ProductTableAdapter.Fill(ProductDataSet.Product)
End Sub

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.

3. What are the features of J2EE?


Features Of J2EE:
 Component based model

CS T73 [PLATFORM TECHNOLOGY] Page 34


 Container provided services

 Highly Scalable

 Simplified Architecture

 Flexible security model

4. Write about the J2EE architecture?

J2EE architecture supports component-based development of multi-tier


enterprise applications. A J2EE application system typically includes the following
tiers:

 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.

5. What makes J2EE suitable for distributed multitiered Applications?


The J2EE platform uses a multitiered distributed application model.
Application logic is divided into components according to function, and the
various application components that make up a J2EE application are installed on
different machines depending on the tier in the multitiered J2EE environment to
which the application component belongs. The J2EE application parts are:
 Client-tier components run on the client machine.
 Web-tier components run on the J2EE server.
 Business-tier components run on the J2EE server.
 Enterprise information system (EIS)-tier software runs on the EIS server.

6. What are the supporting J2EE APIs?


J2EE provides a number of “supporting” APIs. The purpose of most of these
APIs is to enable interaction between the “main” software layers/components in
the J2EE architecture.
•Remote Method Interface (RMI)
•Java Naming and Directory Interface (JNDI)
•Java Message Service (JMS)
•Java Transaction API (JTA)
•Java Database Connectivity (JDBC) / SQLJ
•JavaMail /JMC
7. What do Enterprise JavaBeans components contain?
Enterprise JavaBeans components contains Business code, which is logic
that solves or meets the needs of a particular business domain such as banking,
retail, or finance, is handled by enterprise beans running in the business tier. All
the business code is contained inside an Enterprise Bean which receives data
from client programs, processes it (if necessary), and sends it to the enterprise
information system tier for storage. An enterprise bean also retrieves data from
storage, processes it (if necessary), and sends it back to the client program
8. What can be considered as a web component?

CS T73 [PLATFORM TECHNOLOGY] Page 35


J2EE Web components can be either servlets or JSP pages. Servlets are
Java programming language classes that dynamically process requests and
construct responses. JSP pages are text-based documents that execute as servlets
but allow a more natural approach to creating static content.
9. What is the container?
Containers are the interface between a component and the low-level
platform specific functionality that supports the component. Before a Web,
enterprise bean, or application client component can be executed, it must be
assembled into a J2EE application and deployed into its container.
10. What is the web container?
Servlet and JSP containers are collectively referred to as Web containers. It
manages the execution of JSP page and servlet components for J2EE
applications. Web components and their container run on the J2EE server.
11. What is Enterprise JavaBeans (EJB) container?
It manages the execution of enterprise beans for J2EE applications.
Enterprise beans and their container run on the J2EE server.
12. What are container services?
A container is a runtime support of a system-level entity. Containers
provide components with services such as lifecycle management, security,
deployment, and threading.
13. What is the web container?
Servlet and JSP containers are collectively referred to as Web containers. It
manages the execution of JSP page and servlet components for J2EE
applications. Web components and their container run on the J2EE server.
14. What is Enterprise JavaBeans (EJB) container?
It manages the execution of enterprise beans for J2EE applications.
Enterprise beans and their container run on the J2EE server.
15. What is Applet container?
Manages the execution of applets. Consists of a Web browser and Java
Plugin running on the client together.

16. How do we package J2EE components?


J2EE components are packaged separately and bundled into a J2EE
application for deployment. Each component, its related files such as GIF and
HTML files or server-side utility classes, and a deployment descriptor are
assembled into a module and added to the J2EE application. A J2EE application
is composed of one or more enterprise bean,Web, or application client component
modules. The final enterprise solution can use one J2EE application or be made
up of two or more J2EE applications, depending on design requirements. A J2EE
application and each of its modules has its own deployment descriptor. A
deployment descriptor is an XML document with an .xml extension that describes
a component’s deployment settings.
17. What are types of J2EE clients?
Following are the types of J2EE clients:
 Applets
 Application clients
 Java Web Start-enabled rich clients, powered by Java Web Start
technology.
 Wireless clients, based on Mobile Information Device Profile (MIDP)
technology.

18. What is deployment descriptor?


A deployment descriptor is an Extensible Markup Language (XML) text-
based file with an .xml extension that describes a component’s deployment
settings. A J2EE application and each of its modules has its own deployment
descriptor. For example, an enterprise bean module deployment descriptor

CS T73 [PLATFORM TECHNOLOGY] Page 36


declares transaction attributes and security authorization for an enterprise bean.
Because deployment descriptor information is declarative, it can be changed
without modifying the bean source code. At run time, the J2EE server reads the
deployment descriptor and acts upon the component accordingly.
19. What is the EAR file?
An EAR file is a standard JAR file with an .ear extension, named from
Enterprise ARchive file. A J2EE application with all of its modules is delivered in
EAR file.
20. What is JTA and JTS?
JTA is the abbreviation for the Java Transaction API. JTS is the
abbreviation for the Jave Transaction Service. JTA provides a standard interface
and allows you to demarcate transactions in a manner that is independent of the
transaction manager implementation. The J2EE SDK implements the transaction
manager with JTS. Therefore, JTA is a high level transaction interface that your
application uses to control transaction. and JTS is a low level transaction
interface and ejb uses behind the scenes (client code doesn’t directly interact with
JTS. It is based on object transaction service(OTS) which is part of CORBA.
21. What is JAXP?
JAXP stands for Java API for XML. XML is a language for representing and
describing text-based data which can be read and handled by any program or tool
that uses XML APIs. It provides standard services to determine the type of an
arbitrary piece of data, encapsulate access to it, discover the operations available
on it, and create the appropriate JavaBeans component to perform those
operations.
22. What is J2EE Connector?
The J2EE Connector API is used by J2EE tools vendors and system
integrators to create resource adapters that support access to enterprise
information systems that can be plugged into any J2EE product. Each type of
database or EIS has a different resource adapter. Note: A resource adapter is a
software component that allows J2EE application components to access and
interact with the underlying resource manager. Because a resource adapter is
specific to its resource manager, there is typically a different resource adapter for
each type of database or enterprise information system.
23. What is JAAP?
The Java Authentication and Authorization Service (JAAS) provides a way
for a J2EE application to authenticate and authorize a specific user or group of
users to run it. It is a standard Pluggable Authentication Module (PAM) framework
that extends the Java 2 platform security architecture to support user-based
authorization.
24. Explain about the J2EE multi tier application?
J2EE multi-tiered applications are generally considered to be three-tiered
applications because they are distributed over three different locations
 Client machines
 The J2EE server machine
 The database or legacy machines at the back end

25. Explain diagrammatically the J2EE Server and Containers?

CS T73 [PLATFORM TECHNOLOGY] Page 37


J2EE Server and Containers
26. Where can we apply the best practices throughout the development life
cycle?

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

CS T73 [PLATFORM TECHNOLOGY] Page 38

You might also like