Vous êtes sur la page 1sur 15

Ans 1.

The DataGrid control is a spreadsheet-like bound control that displays a


series of rows and columns representing records and fields from a Recordset object.
You can use the DataGrid to create an application that allows the end user to read
and write to most databases. The DataGrid control can be quickly configured at
design time with little or no code. When you set the DataGrid control's DataSource
property at design time, the control is automatically filled and its column headers
are automatically set from the data source's recordset. You can then edit the grid's
columns; delete, rearrange, add column headers to, or adjust any column's width.
Ans2.

The FileSystemObject, or FSO, is an often used component to access the web server's file
system. For example, you can create files, read the contents of files, determine whether or not a
folder or file exists, iterate through the contents of a folder or directory, or any other number of
file system-related tasks. You can create an instance of the FileSystemObject component in an
ASP page with the following code:
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

Ans3.

Applet

Application

Small Program

Large Program

Used to run a program on client Browser

Can be executed on stand alone computer


system

Applet is portable and can be executed by any


JAVA supported browser.

Need JDK, JRE, JVM installed on client


machine.

Applet applications are executed in a Restricted


Environment

Application can access all the resources of the


computer

Applets are created by extending the


java.applet.Applet

Applications are created by writing public


static void main(String[] s) method.

Applet application has 5 methods which will be


automatically invoked on occurance of specific
event

Application has a single start point which is


main method

Example:
import java.awt.*;
import java.applet.*;
public class Myclass extends Applet
{
public void init() { }
public void start() { }
public void stop() {}

public class MyClass


{
public static void main(String
args[]) {}
}

public void destroy() {}


public void paint(Graphics g) {}

Ans4.

Ans5.

Explain Differences Between C , C++, and Java


1) C Uses header Files but java uses Packages
2)
C
Uses
Pointers
but
java
doesnt
supports
pointers
3)
Java doesnt supports storage classes like auto, external etc.
4) The Code of C Language is Converted into the Machine code after Compilation But
in Java Code First Converted into the Bytes Codes then after it is converted into the
Machine
Code
5)
C++ supports Operator Overloading but java doesnt Supports Operator
Overloading
6) In C++ Multiple Inheritance is Possible but in java A Class Can not Inherit the
features from the two classes in other words java doesnt supports Multiple Inheritance
The Concept of Multiple Inheritances is Introduced in the Form of Interfaces
7) Java Uses import statement for including the contents of screen instead of #include
8) Java Doesnt uses goto
9) Java Doesnt have Destructor like C++ Instead Java Has finalize Method
10) Java Doesnt have Structure Union , enum data types
Ans 6.

A stream can be defined as a sequence of data. The InputStream is used to read data from a
source and the OutputStream is used for writing data to a destination. InputStream and
OutputStream are the basic stream classes in Java.
All the other streams just add capabilities to the basics, like the ability to read a whole chunk of
data at once for performance reasons (BufferedInputStream) or convert from one kind of
character set to Java's native unicode (Reader), or say where the data is coming from
(FileInputStream, SocketInputStream and ByteArrayInputStream, etc.)

Why we need Stream Classes?

To perform read and write operation on binary files we need a mechanism to read that binary
data on file/to write binary data (i.e. in the form of byte). These classes are capable to read and
write one byte on binary files. Thats why we use Stream Classes.
Ans 7.
A device context is a structure that defines a set of graphic objects and their associated attributes,
as well as the graphic modes that affect output. The graphic objects include a pen for line
drawing, a brush for painting and filling, a bitmap for copying or scrolling parts of the screen, a
palette for defining the set of available colors, a region for clipping and other operations, and a
path for painting and drawing operations. The remainder of this section is divided into the
following three areas.
Ans8.
Pascal encourages modular programming, where a program is created from a number of smaller
and simpler pieces known as modules. Modules can make call other modules (i.e. execute other
modules), or even call themselves. Pascal supports two kinds of modules, which are called
functions and procedures.
Functions are called in expressions, and each function call has a value in an expression.
Procedures on the other hand are called in procedure statements. In all other respects functions
and procedures are identical, and the generic term subroutine will be used to refer to both types
of modules.
Sometimes it is useful to create subroutines that accept input data and/or produce output data.
One way to achieve this to have the subroutines use global variables (i.e. variables declared in
the main program block) to store the input and output data. However the overuse of global
variables can make programs difficult to understand and change. The basic problem is that since
gloval variables are not specific to any particular subroutine, it can be difficult to keep track of
which subroutines use which global variables and when. As a result, subroutines can become
tightly intertwined making it very difficult to change one subroutine without changing the others.
Ans9/
Generic Programming is a programming paradigm for developing efficient, reusable software
libraries. Pioneered by Alexander Stepanov and David Musser, Generic Programming obtained
its first major success when the Standard Template Library became part of the ANSI/ISO C++
standard. Since then, the Generic Programming paradigm has been used to develop many generic
libraries.
The Generic Programming process focuses on finding commonality among similar
implementations of the same algorithm, then providing suitable abstractions so that a single,

generic algorithm can cover many concrete implementations. This process, called lifting, is
repeated until the generic algorithm has reached a suitable level of abstraction, where it provides
maximal reusability while still yielding efficient, concrete implementations. The abstractions
themselves are expressed as requirements on the parameters to the generic algorithm.
Ans10.

Read information from HTTP, FTP, and gopher servers as easily as reading files from a
hard drive.

Use HTTP, FTP, and gopher protocols without programming directly to WinSock or
TCP/IP.
Developers who use the Win32 Internet functions do not need to be familiar with TCP/IP
or Windows Sockets. You can still program at the socket level, using WinSock and
TCP/IP protocols directly, but it's even easier to use the MFC WinInet classes to access
HTTP, FTP, and gopher protocols across the Internet. For many common operations,
developers do not need to know the details of the particular protocol they are using.

Many operations that can be performed by your computer as a client to other computers on the
Internet can take a long time. The speed of these operations is usually limited by the speed of
your network connection, but they can also be affected by other network traffic and the
complexity of the operation. Connecting to a remote FTP server, for example, requires that your
computer first look up the name of that server to find its address. Your application will then
attempt to connect to the server at that address. Once the connection is opened, your computer
and the remote server will initiate a conversation with the file transfer protocol before you can
actually use the connection to retrieve files.
Ans11.

Modal and Modeless Dialog Boxes


Dialog boxes are either modal or modeless. A modal dialog box must be closed (hidden or
unloaded) before you can continue working with the rest of the application. For example, a
dialog box is modal if it requires you to click OK or Cancel before you can switch to another
form or dialog box.
The About dialog box in Visual Basic is modal. Dialog boxes that display important messages
should always be modal that is, the user should always be required to close the dialog box or
respond to its message before proceeding.
Modeless dialog boxes let you shift the focus between the dialog box and another form without
having to close the dialog box. You can continue to work elsewhere in the current application
while the dialog box is displayed. Modeless dialog boxes are rare. From the Edit menu, the Find

dialog box in Visual Basic is an example of a modeless dialog box. Use modeless dialog boxes to
display frequently used commands or information.
To display a form as a modal dialog box

Use the Show method with a style argument of vbModal (a constant for the value 1).
For example:
' Display frmAbout as a modal dialog.
frmAbout.Show vbModal

To display a form as a modeless dialog box

Use the Show method without a style argument.


For example:
' Display frmAbout as a modeless dialog.
frmAbout.Show

Note If a form is displayed as modal, the code following the Show method is not executed until
the dialog box is closed. However, when a form is shown as modeless, the code following the
Show method is executed immediately after the form is displayed.
The Show method has another optional argument, owner, that can be used to specify a parentchild relationship for a form. You can pass the name of a form to this argument to make that form
the owner of the new form.
To display a form as a child of another form

Use the Show method with both style and owner arguments.
For example:
' Display frmAbout as a modeless child of frmMain.
frmAbout.Show vbModeless, frmMain

Using the owner argument with the Show method ensures that the dialog box will be minimized
when its parent is minimized, or unloaded should the parent form be closed.
Ans13
Java Generic methods and generic classes enable programmers to specify, with a single method
declaration, a set of related methods, or with a single class declaration, a set of related types,
respectively.

Generics also provide compile-time type safety that allows programmers to catch invalid types at
compile time.
Using Java Generic concept, we might write a generic method for sorting an array of objects,
then invoke the generic method with Integer arrays, Double arrays, String arrays and so on, to
sort the array elements.

Generic Methods
You can write a single generic method declaration that can be called with arguments of different
types. Based on the types of the arguments passed to the generic method, the compiler handles
each method call appropriately. Following are the rules to define Generic Methods

All generic method declarations have a type parameter section delimited by angle
brackets (< and >) that precedes the method's return type ( < E > in the next example).

Each type parameter section contains one or more type parameters separated by commas.
A type parameter, also known as a type variable, is an identifier that specifies a generic
type name.

The type parameters can be used to declare the return type and act as placeholders for the
types of the arguments passed to the generic method, which are known as actual type
arguments.

A generic method's body is declared like that of any other method. Note that type
parameters can represent only reference types, not primitive types (like int, double and
char).

Example

Following example illustrates how we can print an array of different type using a single Generic
method
public class GenericMethodTest {
// generic method printArray
public static < E > void printArray( E[] inputArray ) {
// Display array elements
for(E element : inputArray) {
System.out.printf("%s ", element);
}
System.out.println();
}
public static void main(String args[]) {
// Create arrays of Integer, Double and Character
Integer[] intArray = { 1, 2, 3, 4, 5 };
Double[] doubleArray = { 1.1, 2.2, 3.3, 4.4 };
Character[] charArray = { 'H', 'E', 'L', 'L', 'O' };

System.out.println("Array integerArray contains:");


printArray(intArray);
// pass an Integer array
System.out.println("\nArray doubleArray contains:");
printArray(doubleArray);
// pass a Double array
System.out.println("\nArray characterArray contains:");
printArray(charArray);
// pass a Character array
}

This will produce the following result


Output
Array integerArray contains:
1 2 3 4 5
Array doubleArray contains:
1.1 2.2 3.3 4.4
Array characterArray contains:
H E L L O

Ans14.
There are two data types available in Java

Primitive Data Types

Reference/Object Data Types

Primitive Data Types


There are eight primitive datatypes supported by Java. Primitive datatypes are predefined by the
language and named by a keyword. Let us now look into the eight primitive data types in detail.
byte

Byte data type is an 8-bit signed two's complement integer

Minimum value is -128 (-2^7)

Maximum value is 127 (inclusive)(2^7 -1)

Default value is 0

Byte data type is used to save space in large arrays, mainly in place of integers, since a
byte is four times smaller than an integer.

Example: byte a = 100, byte b = -50

short

Short data type is a 16-bit signed two's complement integer

Minimum value is -32,768 (-2^15)

Maximum value is 32,767 (inclusive) (2^15 -1)

Short data type can also be used to save memory as byte data type. A short is 2 times
smaller than an integer

Default value is 0.

Example: short s = 10000, short r = -20000

Int data type is a 32-bit signed two's complement integer.

Minimum value is - 2,147,483,648 (-2^31)

Maximum value is 2,147,483,647(inclusive) (2^31 -1)

Integer is generally used as the default data type for integral values unless there is a
concern about memory.

The default value is 0

Example: int a = 100000, int b = -200000

int

long

Long data type is a 64-bit signed two's complement integer

Minimum value is -9,223,372,036,854,775,808(-2^63)

Maximum value is 9,223,372,036,854,775,807 (inclusive)(2^63 -1)

This type is used when a wider range than int is needed

Default value is 0L

Example: long a = 100000L, long b = -200000L

float

Float data type is a single-precision 32-bit IEEE 754 floating point

Float is mainly used to save memory in large arrays of floating point numbers

Default value is 0.0f

Float data type is never used for precise values such as currency

Example: float f1 = 234.5f

double

double data type is a double-precision 64-bit IEEE 754 floating point

This data type is generally used as the default data type for decimal values, generally the
default choice

Double data type should never be used for precise values such as currency

Default value is 0.0d

Example: double d1 = 123.4

boolean

boolean data type represents one bit of information

There are only two possible values: true and false

This data type is used for simple flags that track true/false conditions

Default value is false

Example: boolean one = true

char

char data type is a single 16-bit Unicode character

Minimum value is '\u0000' (or 0)

Maximum value is '\uffff' (or 65,535 inclusive)

Char data type is used to store any character

Example: char letterA = 'A'

Reference Datatypes

Reference variables are created using defined constructors of the classes. They are used
to access objects. These variables are declared to be of a specific type that cannot be
changed. For example, Employee, Puppy, etc.

Class objects and various type of array variables come under reference datatype.

Default value of any reference variable is null.

A reference variable can be used to refer any object of the declared type or any
compatible type.

Example: Animal animal = new Animal("giraffe");

Ans15.

Features of Java
1. Features of Java
1. Simple
2. Object-Oriented
3. Platform Independent
4. secured
5. Robust
6. Architecture Neutral
7. Portable
8. High Performance
9. Distributed
10.Multi-threaded

There is given many features of java. They are also known as java buzzwords. The Java Features

given below are simple and easy to understand.


1. Simple
2. Object-Oriented
3. Platform independent
4. Secured
5. Robust
6. Architecture neutral
7. Portable
8. Dynamic
9. Interpreted
10.High Performance
11.Multithreaded
12.Distributed

Simple
According to Sun, Java language is simple because:
syntax is based on C++ (so easier for programmers to learn it after C++).
removed many confusing and/or rarely-used features e.g., explicit pointers,
operator overloading etc.
No need to remove unreferenced objects because there is Automatic Garbage
Collection in java.

Object-oriented
Object-oriented means we organize our software as a combination of different
types of objects that incorporates both data and behaviour.
Object-oriented programming(OOPs) is a methodology that simplify software
development and maintenance by providing some rules.
Basic concepts of OOPs are:

1. Object
2. Class
3. Inheritance
4. Polymorphism
5. Abstraction

6. Encapsulation
Platform Independent

A platform is the hardware or software environment in which a program runs.


There are two types of platforms software-based and hardware-based. Java provides software-

based platform.
The Java platform differs from most other platforms in the sense that it is a
software-based platform that runs on the top of other hardware-based platforms. It
has two components:
1. Runtime Environment
2. API(Application Programming Interface)

Java code can be run on multiple platforms e.g. Windows, Linux, Sun Solaris, Mac/OS etc. Java
code is compiled by the compiler and converted into bytecode. This bytecode is a platformindependent code because it can be run on multiple platforms i.e. Write Once and Run
Anywhere(WORA).

Secured

Java is secured because:

No explicit pointer

Java Programs run inside virtual machine sandbox

Classloader: adds security by separating the package for the classes of the
local file system from those that are imported from network sources.

Bytecode Verifier: checks the code fragments for illegal code that can

violate access right to objects.

Security Manager: determines what resources a class can access such as


reading and writing to the local disk.

These security are provided by java language. Some security can also be provided by application
developer through SSL, JAAS, Cryptography etc.

Robust

Robust simply means strong. Java uses strong memory management. There are lack of pointers
that avoids security problem. There is automatic garbage collection in java. There is exception
handling and type checking mechanism in java. All these points makes java robust.

Architecture-neutral

There is no implementation dependent features e.g. size of primitive types is fixed.


In C programming, int data type occupies 2 bytes of memory for 32-bit architecture and 4 bytes
of memory for 64-bit architecture. But in java, it occupies 4 bytes of memory for both 32 and 64
bit architectures.

Portable

We may carry the java bytecode to any platform.

High-performance
Java is faster than traditional interpretation since byte code is "close" to native
code still somewhat slower than a compiled language (e.g., C++)

Distributed
We can create distributed applications in java. RMI and EJB are used for creating
distributed applications. We may access files by calling the methods from any
machine on the internet.

Multi-threaded

A thread is like a separate program, executing concurrently. We can write Java programs that
deal with many tasks at once by defining multiple threads. The main advantage of multi-

threading is that it doesn't occupy memory for each thread. It shares a common memory area.
Threads are important for multi-media, Web applications etc.

Vous aimerez peut-être aussi