Friday, 29 July 2011

How to run Java program

A First Simple Program /* This is a simple program Call this file “Example.java”. */ Class Example { //Your program begins with a call to main (). Public static void main (String args[]) { System.out.println (“This is a simple Java program “); } } Entering the program -The name of a source file is very important -In Java, all code must reside inside a class. By convention ,the name of that class should match the name of the file that holds the program -A source file use the .java filename extension Compilling the Program C:>\javac Example...

Features of java programming language

Compiled and interpreted Platform – IndependentObject – OrientedRobust and SecureDistributedMultithreaded Dynamic and Extensible Compiled and interpreted:-                Usually a computer language is either compiled or interpreted. Java combines both these approaches thus making Java a two stage system. First, Java compiler translates sources code into what is known as byte code instruction. Byte codes are not machine instructions and therefore, in the second stage. Java...

Thursday, 28 July 2011

Program to enter a 5*5 matrix and display it

class matrix{Public static void main (String arg []){int two [] [] = new int [5] [5];{int i,j,k =0;for (i= 0; i<5 ; i++) {for (j=0 ; j<5; j++){Two [i] [j] = k;k++;} }for (i=0; k=5 ;i++){for (j=0; j<5 ; j++){System.out.print( two [i] [i] + “  “ );}System.out.println( );}...

A simple program to arrange the 10 nos. in ascending order using array.

class ASC{Public static void main (String arg[]){int I,j,k;int a[] ={10,12,18,16,3};for (i=1;i<5;i++){for(j=0;j<=3;j++){if(a[j] > = a [ j+ 1]){k=a [j];a[j]=a[j+1]a[j+1]=k;}}}for(i=0;i<5;i++){System.out.println (a [i]);...

A simple program to find the average of 10 nos. using array class Arg

class Arg{Public static void main (string arg []){int no []= { 10 ,12 , 14 ,16 ,18 ,20 ,22, 24 ,26 28);int result = 0;for (i=0; i<10;i++)result =result + no [i];System.out.println(“Average is “ +result/10)...

Wednesday, 27 July 2011

Structure of JAVA program

 A JAVA program may contains many classes of which only one class defines a main method. Classes contain data members and methods that operated on the data members of the class. Methods may contain data type declaration and executed statements. To write a Java program, we first define classes and then put them together. A Java program may contain one or more sections...

Simple program for printing the following chatuskon upto given value and print the patter for “*”

                        *                                                                                                   ...

simple program for printing the following pyramid using for loop

                                                            1                  2                ...

Program for Printing the following pyramid

12 23 3 34 4 4 4n n n ………………n class series{ Public static void main (String args[]){ int i,j,n;n=50; for(i=1;i<=50; i++ ) { for(j=1;j<=1;j++) { system.out.print (i); } system.out.println (“ “); ...

Simple program for making Pyramid using only while loop

11 2 1 2 31 2 3 41 2 3 4…..N class series{ Public static void main (String args []) { int N=10; i=1; j=1;while( i<N) { j=1;while(J<=i) { System.out.println(j);J++; } System.out.println(“”);i++; }}} ...

Program to find the greater number from the three nos. using nested if else statement

Classs max{             Public static void main (String args[])               { Int a,b,c;A=25; b=30; c=10;if(a>b)              { if(a<c) System.out.println(“a is maximum”); else System.out.println(“c is maximum”); }else if(b>c) System.out.printl(“b is maximum”); else System.out.printl(“c is maximum”);}              ...

A simple program for addition of two values:

Class addition{Public static void main (String args[])   {int a = 5, b=10;int c= a+ b; System.out.println(“the sum of two value is :” +c);    ...

The Java Runtime Environment

The Java Runtime Environment (JRE) consists of the JVM and the program on the other. The Java Runtime Environment runs code compiled for the JVM by: Loading the .class filesVerifying byte codeExecuting the c...

Just in Time Compilers (JIT)

-The Java Virtual Machine includes an optional ‘just-in time’ (JIT) compiler.-The JIT:        -Dynamically compilers byte code into executable code       -Takes byte codes and compilers them into native code for the machine       -Compiles programs on a methods by method basis just before they are called       -Is faster than the Java Virtual Mach...

Process of compilation

...

Java virtual Machine

All language compilers translate source code into machine code for a specific computer. Java compiler produces an intermediate code known as byte-code for a machine. This machine is called Java Virtual Machine (JVM ) and it exists only inside the computer’s memory. It is simulator of computer wihin the computer and does all major functions of a real computer.                                                     ...

Tuesday, 26 July 2011

Process of building and running java application programs

...

Difference Between applet and application

Application Application can be directly executed by a Java.exe toolJava Interpreters runs the applicationWe require JVM to run java application program. AppletApplet require web browser for their execution. Their execution is embedded within web pages .Applet viewer can be used to run an applet.An applet written by any developer in the world may be dynamically download from a web server and executed on a client PC...

Data Types

 Data types-Integers-long (64 bit)-Int(16 bit)-short(16,bit)-byte(8 bit)-Floating-pointer numbers-double(64 bit)-float(32 bit)-Characters(char, 16 bit)-Booleans (Boolean, true or false) Arrays-Arrays in Java work differently than they do in other languages-First declare the array                        Int month_days=new int[12];-Arrays can be initialized during declaration -Multidimensional arrays                       ...

Java’s Magic: The Bytecode

The secrets behind the security and portability of Java is that the output of a Java computer is not executable code.Rather, it is Bytecode  Bytecode is a highly optimized set of instructions designed to be executed by the Java run-time system, which is called the Java Virtual Machine (JVM)JVM is an interpreter of Bytecode         Java systems contain:-Environment -Language-APIs-Class librariesJava programs normally undergo five phases(1)    Edit-Programmer writes program )and stores program...

Twitter Delicious Facebook Digg Stumbleupon Favorites More