Tuesday, June 12, 2012

Java : Advantages, Scope and Future

 
JAVA is an object oriented programming language and it was intended to serve as a new way to manage software complexity. Java refers to a number of computer software products and specifications from Sun Microsystems that together provide a system for developing application software and deploying it in a cross-platform environment. Java is used in a variety of computing platforms from embedded devices and mobile phones on the low end, to enterprise servers and supercomputers on the high end. Java is nearly everywhere in mobile phones, Web servers and enterprise applications, and while less common on desktop computers; Java applets are often used to provide improved functionality while browsing the World Wide Web.

Some advantages of JAVA:

  • It is an open source, so users do not have to struggle with heavy license fees each year
  • Platform independent
  • Java API's can easily be accessed by developers
  • Java perform supports garbage collection, so memory         management is automatic
  • Java always allocates objects on the stack
  • Java embraced the concept of exception specifications
  • Multi-platform support language and support for web-services
  • Using JAVA we can develop dynamic web applications
  • It allows you to create modular programs and reusable codes


Another advantage of JAVA is that, ones the program is written in java we can run it anywhere means that application developed through Java is platform independent. JAVA based enterprise applications perform well because stable JAVA standards help developers to create multilevel applications with a component based approach.


JAVA programming enables secure and high performance software development on multiple platforms. Many companies in India have well-qualified software engineers having expertise in Java, Java Script, J2SE, JSP, and J2ME, JAVA Programming Services help your businesses to do better. They provide variety of Java development services including project solutions.

Sunday, June 10, 2012

WHILE LOOP:

 WHILE LOOP:

Syntax: 
     
while( <condition> )
{
        <loop body>
 }

PROGRAM:
public class Example
 {
  public static void main(String[] args) 
  {   
     int i = 0; 
     while(i < 5)
     {
       System.out.println("i is : " + i);
       i++;
     }
  }
}
Output:
i is : 0
i is : 1
i is : 2
i is : 3
i is : 4
TRY YOURSELF: 10
1)Write a java program to display the numbers between 25 and 50 for teaching numbers for Ravi.generate the numbers using while loop.

Wednesday, June 6, 2012

/* Program to display numbers between 1 to 5*/

SYNTAX:
Do 
{
         <Block of statements>;
}while(<boolean condition>);
PROGRAM:
/* Program to display numbers between 1 to 5*/
public class ex
{
  public static void main(String[] args)  
{

     int i =0; 
    do
    {
       System.out.println("i is : " + i);
        i++;
     }while(i < 5);
   
  }
}
SAMPLE OUTPUT:
i is : 0
i is : 1
i is : 2
i is : 3
i is : 4
TRY YOURSELF:9
1)Write a program to display the numbers between 25 to 50.

FOR LOOP

  • For loop executes group of Java statements as long as the boolean condition evaluates to true.
For loop combines three elements which we generally use: initialization statement, boolean expression and increment or decrement statement.
For loop syntax
for( <initialization> ; <condition> ; <statement> ) 
{
        <Block of statements>;
}

  • The initialization statement is executed before the loop starts. It is generally used to initialize the loop variable.
  • Condition statement is evaluated before each time the block of statements are executed. Block of statements are executed only if the boolean condition evaluates to true.
  • Statement is executed after the loop body is done. Generally it is being used to increment or decrement the loop variable.
It is possible to initialize multiple variable in the initialization block of the for loop by separating it by comma as given in the below example.
  1. for(int i=0, j =5 ; i < 5 ; i++)

It is also possible to have more than one increment or decrement section as well as given below.
  1. for(int i=0; i < 5 ; i++, j--)

However it is not possible to include declaration and initialization in the initialization block of the for loop. Also, having multiple conditions separated by comma also generates the compiler error. However, we can include multiple condition with && and || logical operators.

PROGRAM:

/*PROGRAM TO PRINT EVEN NUMBERS*/
public class ListEvenNumbers
 {
        public static void main(String[] args)  
         {
                int limit = 50;    
                System.out.println("Printing Even numbers between 1 and " + limit);
                for(int i=1; i <= limit; i++) 
                 {
               // if the number is divisible by 2 then it is even
                      if( i % 2 == 0)
                     {
                                System.out.print(i + " ");
                      }
                }
        }
}

TRY YOURSELF:8
1)Write a program to print odd numbers between 1 and 20 using for loop.

Tuesday, June 5, 2012

Else-if statement

Else-if statement

Syntax
if (condition)
 {
statements;
}
 else if (condition) 
{
statements;
}
 else
 {
statements;
}

Program:
 import.java.io.*;
class colour
{
    public static void main(string args[])
    { 
      int color=2
         if(color == 1)) 
         {
            System.out.println("The color is blue.");
         }
         else if(color == 2)
        {
            System.out.println("The color is green.");
        }
       else
     { 
      System.out.println("The color is Red.");
     }
    }
}

Sample Output:
The color is green.
Try Yourself:
1)write a program with your concept using elseif statement

Sunday, June 3, 2012

Basic Programming-6

Switch Statements in Java

 switch ( variable_to_test )
 {
case value:
code_here;
break;
case value:
code_here;
break;
default:
values_not_caught_above;
}

Program:
 
import.java.io.*; 
class month 
{
    public static void main(String[] args)
      {
        int month = 7;
        switch (month) 
        {            
            case 1:  System.out.println("January"); break;
            case 2:  System.out.println("February"); break;
            case 3:  System.out.println("March"); break;
            case 4:  System.out.println("April"); break;
            case 5:  System.out.println("May"); break;
            case 6:  System.out.println("June"); break;
            case 7:  System.out.println("July"); break;
            case 8:  System.out.println("August"); break;
            case 9:  System.out.println("September"); break;
            case 10: System.out.println("October"); break;
            case 11: System.out.println("November"); break;
            case 12: System.out.println("December"); break;
            default: System.out.println("Invalid month.");break;
        }
    }
}

Sample output:
July

Try Yourself:6
1)Write a program to perform Arithmatic Operations using Switch statements

Note:Answer will be published after 24hrs on the solution page of this blog.

Saturday, June 2, 2012

If-Else Statement:

If-Else Statement:

The if-else class of statements should have the following form:
 if (condition) 
{
statements;
else 
{
statements;
}

PROGRAM:
import.java.io.*;
public class divisor
{
public static void main(String[] args)

{
         int a = 10;
         int b = 2;
         if ( a % b == 0 )
         {
               System.out.println(a + " is divisible by "+ b);
         }
         else
         {
               System.out.println(a + " is not divisible by " + b);
         }
}


TRY YOURSELF:5
1)Write a program to whether the Arun is eligible to vote age limit to vote must be 18 years,use if else statement and display his eligibility.
Animated Social Gadget - Blogger And Wordpress Tips