Your Ad Here

Friday 6 January 2012

Write a Program to explain the concept of Arithmetic Operators in java


class arithemetic
{
            public static void main(String args[])
            {
                        float a=12, b=2;
                        System.out.println("a= " +a);
                        System.out.println("b= " +b);
                        System.out.println("a+b= " +(a+b));
                        System.out.println("a-b= " +(a-b));
                        System.out.println("a*b= " +(a*b));
                        System.out.println("a/b= " +(a/b));
                        System.out.println("a%b= " +(a%b));
            }
}

# Write a program to add two numbers using function in java


class add
          {
            void add1 (int x,int y)
            {
                        int c=x+y;
                        System.out.println("The Result is:" +c);
            }
}

class main
{
            public static void main(String args[])
            {
                        add a=new add();
                        a.add1(2,3);
            }
}

Write a program to display a simple text on the screen in java


class a
{
            public static void main(String args[])
            {
                        System.out.println("Hello!!!!");
            }
}






Working with Images in .NET Framework

Friends i am B.TECH Engineer(I.T) . Hopefully these notes may help u.


Working with Images
The .NET Framework provides tools to work with a variety of image formats, enabling you to perform many common image-editing tasks.

The Image and Bitmap Classes
The System.Drawing.Image abstract class gives you the ability to create, load, modify, and save images such as .BMP files, .JPG files, and .TIF files.

The Image class is abstract, but you can create instances of the classing using the Image.FromFile (which accepts a path to an image file as a parameter) and Image.From- Stream (which accepts a System.IO.Stream object as a parameter) methods. You can also use two classes that inherit Image: System.Drawing.Bitmap for still images, and System.Drawing.Imaging.Metafile for animated images.

Bitmap is the most commonly used class for working with new or existing images. The different constructors allow you to create a Bitmap from an existing Image, file, or stream, or to create a blank bitmap of a specified height and width. Bitmap contains two particularly useful methods that Image lacks:

GetPixel Returns a Color object describing a particular pixel in the image. A pixel is a single colored dot in the image, consisting of a red, green, and blue component.

SetPixel Sets a pixel to the specified color.
How to Display Pictures

To display an image that is saved to the disk in a form, load it with Image.FromFile and create a PictureBox control, and then use the Image to define PictureBox.Background-Image

// C#
Image i = Image.FromFile(@"C:\windows\gone fishing.bmp");
pictureBox1.BackgroundImage = i;

Similarly, the following code accomplishes the same thing using the Bitmap class:
// C#
Bitmap b = new Bitmap(@"C:\windows\gone fishing.bmp");
pictureBox1.BackgroundImage = b;
Alternatively, you can display an image as the background for a form or control by using the Graphics.DrawImage method.

// C#
Bitmap bm = new Bitmap(@"C:\WINDOWS\Web\Wallpaper\Azul.jpg");
Graphics g = this.CreateGraphics();
g.DrawImage(bm, 1, 1, this.Width, this.Height);

How to Create and Save Pictures

To create a new, blank picture, create an instance of the Bitmap class with one of the constructors that does not require an existing image. You can then edit it using the Bitmap.SetPixel method, or you can call Graphics.FromImage and edit the image using the Graphics drawing methods.

To save a picture, call Bitmap.Save. This method has several easy-to-understand overloads.
Two of the overloads accept a parameter of type System.Drawing.Imaging.Image-Format, for which you should provide one of the following properties to describe the file type: Bmp, Emf, Exif, Gif, Icon, Jpeg, MemoryBmp, Png, Tiff, or Wmf. Jpeg is the most common format for photographs, and Gif is the most common format for charts, screen shots, and drawings.

For example, the following code creates a blank 600-by-600 Bitmap, creates a Graphics object based on the Bitmap, uses the Graphics.FillPolygon and Graphics.DrawPolygon methods to draw a shape in the Bitmap, and then saves it to a file named bm.jpg in the current directory. This code can run as a console application, and it requires the System.Drawing.Drawing2D and System.Drawing.Imaging namespaces.

// C#
Bitmap bm = new Bitmap(600, 600);
Graphics g = Graphics.FromImage(bm);
Brush b = new LinearGradientBrush(new Point(1, 1), new Point(600, 600),

Color.White, Color.Red);
Point[] points = new Point[]
{new Point(10, 10),
new Point(77, 500),
new Point(590, 100),
new Point(250, 590),
new Point(300, 410)};
g.FillPolygon(b, points);
bm.Save("bm.jpg", ImageFormat.Jpeg);
To edit an existing image, simply change the Bitmap constructor in the previous example to load a picture.

How to Use Icons
Icons are transparent bitmaps of specific sizes that are used by Windows to convey status. The .NET Framework provides standard 40-by-40 system icons as properties of the SystemIcons class, including icons for exclamation, information, and question. The simplest way to add an icon to a form or image is to call the Graphics.DrawIcon or Graphics.DrawIconUnstretched methods.

// C#
Graphics g = this.CreateGraphics();
g.DrawIcon(SystemIcons.Question, 40, 40);

You can also edit system icons or load saved icons using the constructors built into the Icon class. Once you create an instance of the Icon class, call Icon.ToBitmap to create a Bitmap object that can be edited.

Encoding and Decoding in .NET Framework

Friends i am B.TECH Engineer(I.T) . Hopefully these notes may help u.

Encoding and Decoding
American Standard Code for Information Interchange (ASCII) is still the foundation for existing encoding types. ASCII assigned characters to 7-bit bytes using the numbers 0 through 127.

More and more, ASCII and ISO 8859 encoding types are being replaced by Unicode. Unicode is a massive code page with tens of thousands of characters that support most languages and scripts, including Latin, Greek, Cyrillic, Hebrew, Arabic, Chinese, and Japanese (and many other scripts).
Unicode itself does not specify an encoding type; however, there are several standards for encoding Unicode. The .NET Framework uses Unicode UTF-16 (Unicode Transformation Format, 16-bit encoding form) to represent characters. In some cases, the .NET Framework uses UTF-8 internally. The System.Text namespace provides classes that allow you to encode and decode characters. System.Text encoding support includes the following encodings:

Unicode UTF-32 encoding Unicode UTF-32 encoding represents Unicode characters as sequences of 32-bit integers. You can use the UTF32Encoding class to convert characters to and from UTF-32 encoding.

Unicode UTF-16 encoding Unicode UTF-16 encoding represents Unicode characters as sequences of 16-bit integers. You can use the UnicodeEncoding class to convert characters to and from UTF-16 encoding.

Unicode UTF-8 encoding Unicode UTF-8 uses 8-bit, 16-bit, 24-bit, and up to 48-bit encoding. Values 0 through 127 use 8-bit encoding and exactly match ASCII values, providing some degree of interoperability. Values from 128 through 2047 use 16-bit encoding and provide support for Latin, Greek, Cyrillic, Hebrew, and Arabic alphabets. Values 2048 through 65535 use 24-bit encoding for Chinese, Japanese, Korean, and other languages that require large numbers of values. You can use the UTF8Encoding class to convert characters to and from UTF-8 encoding.