Tuesday 10 January 2012

Cloud Computing

Basics of Cloud 
In the past computing tasks such as word processing were not possible without the installation of application software on a user's computer. A user bought a license for each application from a software vendor and obtained the right to install the application on one computer system

Cloud computing differs from the classic client-server model by providing applications from a server that are executed and managed by a client's web browser, with no installed client version of an application required. Centralization gives cloud service providers complete control over the versions of the browser-based applications provided to clients, which removes the need for version upgrades or license management on individual client computing devices.

Anshul.

Common C Programs

1. Write a program for factorial of a given number.
#include<stdio.h>
int factorial(int n);
int main()
{
int x,i;
printf("Enter a value for x \n");
scanf("%d",&x);
i=factorial(x);
printf("\n Factorial of %d is %d"x,i);
return 0;
}
int factorial(int n)
{
if(n<=0)
{
return(1);
}
else
{
return(n*factorial(n-1));
}
}

2. Write a program for detecting Even and odd number.
#include<stdio.h>
int main()
{
int a;
printf("Enter the number");
scanf("%d"&a);
if(a%2==0)
{
printf("given number is Even");
}
else
{
printf("given number is Odd");
}
return 0;
}

3. Write a program to swap two numbers using a temporary variable.
#include<stdio.h>
int main()
{
int temp,a,b;
printf("Enter the value of a and b");
scanf("a=%d,b=%d"&a,&b);
temp=a;
a=b;
b=temp;
printf(new value of a=%d and b=%d"a,b);
return 0;
}


4.Write a program for the prime number.
#include<stdio.h>
int main()
{
int n,c;
c=0;
printf("Enter the number");
scanf("%d"&n);
for(int i=1;i<=n;i++)
{
if(n%i==0)
{
c++;
}
}
if(c==2)
{
printf("Number is prime");
}
else
{
printf("number is not prime");
}
return 0;
}

Sunday 8 January 2012

Java Concepts: Exception Handling

Exception Handling- Exception handling is a process in which at run-time, JVM exceptionally (by going out of general way), handle a abnormal condition.If we took a simple example- A person is riding a bike at the speed of 100km/hr.Suddenly a cat came in his way and if he is able to handle the accident than it is called exception. but if accident is occur than it is called error.
There are two kind of exceptions:
  1. Checked Exception-The exception which is known to the compiler is called Checked Exception.
  2. Unchecked Exception-The exception which is not known by the compiler is called Unchecked Exception.
SQL Exception , I/O exception are checked exception. Arthematic Exception,Null pointer Exception are unchecked Exception.
  • try-catch block is used for the exception handling.
  • Throw keyword- Throw is used for throwing exception explicitly.generally we use throw keyword for custom exception.Example-throw new ArthematicException();
  • Throws-Throws clause is used as a indicator which is putted in front of a method.It tells the programmer that if you are using this method than you have to care about the given exceptions,they may be arise due to method implementation.
Anshul.

Your mail are welcomed at java.ansh@gmail.com.

Java Concepts: Construction and Destroying Object

Constructor- Constructor is a operator which is used for creating an object. It is quite similar to the object but have some restriction such as:
  1. A constructor does not have any return type (even not void).
  2. the name of the constructor must be same as the name of the class in which it is defined.
  3. The only modifier that can be used on a constructor definition are the access modifier such as Public, Protected and private.(constructor are never static).
  • Constructor is used for initialization of such objects which have same initial value and we want to put these values at the time of object creation.such as in the industry when we make a entry of fresher than if we want to enter the initial salary at the time of creation than we use it by using constructor.
  • There are two kind of constructor:
  1. Default constructor.
  2. Explicit constructor.



Garbage Collection- Garbage collection is the process of  freeing waste memory for reusing purpose.The memory which is allocated in heap is collected because size of heap is very limited. Only those objects which does not have reference variables are available for garbage collection.There are various situations for the garbage collection :
  1. When null is used after utilization of object.
  2. When we overlap any Object reference.
such as Demo d1=new Demo();
            Demo d2=new demo();
                      d2=d1;

  • We use System.gc() method for requesting JVM for garbage collection.
  • We use finalize() method for giving last instruction to the program to terminate the program.

Anshul.




Friday 6 January 2012

Java Concepts:Inheritance

Inheritance- The term inheritance refers to the fact that one class can inherit part or all of its structure and behavior from another class.The class that does the inheriting is called subclass .Example:
class B extends A{
       ........................
      .........................
    }
     Live Example:
                                           

Java Concepts: Interface and Abstract class

Interface - Interface is nothing but a way of achieving abstraction.There is a drawback in java that it does not allow multiple inheritance.To overcome the problem of multiple inheritance ,concept of interfaces is applied. Interface consist of a set of instance and abstract method prototype(by default public must).When a class wants to use that method than it must be implement that interface and also provide the body of the method.Some more facts about Interface:
  1. Interfaces can't be initiated means we can not form a object of Interface.
  2. variables of interface are public,static and final (by default).
  3. One class may implement more than one interfaces.
  4. One interface can extend other interface.
Example: public interface drawable{   // defining interface.
                    public void draw(Graphics g);
               }
             public class Line implements drawable  { //Implementation.
                  public void draw(Graphics g){
                        .......................
                       .........................
             }

Abstract Class- It is also a way of achieving abstraction.An abstract class is one that is not used to construct  Object , it is used as a base for making subclass.An Abstract class is exist only to express common properties  of all its sub classes.Some important properties of abstract class:

  1. Abstract class can't be initiated means its object can not be formed.
  2. Abstract and non-abstract both kind of method are put into abstract class.
  3. Non-abstract method must declare their body in abstract classes.  
Example: abstract class Base{                    //declare
                               abstract void show();
                   }
               class Child extends Base{             //Implementation
                          void show()
                                       {..........................
                                        ..........................;
                                      }
             }

    OOPs concepts....

    Object Oriented Programming- OOP represents an attempt to make programs more closely model the people think about and deal with the world.

    Object- An object is a software bundle of variables and related methods.

    OOPs Concept-
    1.Encapsulation- Packaging an object variables within the protective custody of its methods is called Encapsulation.Encapsulation provides following benefits:
    a. Modularity
    b.Information-hiding.


                                                                   Encapsulation


    Abstraction-Abstraction is nothing but only showing functionality and hide complexity.In philosophical terminology abstraction is the thought process wherein Ideas are distanced from objects.In computer science, abstraction is a mechanism and practice to reduce and factor out details so that one can focus on few concepts at a time.In Java, Abstraction is achieved  by two ways:
    a.Abstract Classes.
    b.Interfaces.


    Polymorphism- It is nothing but one name multiple form. Behavior of a function differently at different situation is called polymorphism.for Example our behavior change at different situations.It can be achieved by two ways:
    a.Overloading.
    b.Overriding.  



    Polymorphism






                                              

    Wednesday 4 January 2012

    Java Concepts: Overloading and Overriding....

    Overloading: 
    1.When we create same name method within a class with different arguments is
        called overloading.
    2.In Overloading, Compiler decide at the compile time that which method has
        to be called.
    3.The number of arguments or order of arguments must be different.
    4.The return type may be different of  overloaded method.
    5.The access modifier may be different of overloaded method.
    6.Exception can be change.

    Overriding:
    1.If we creates same name method in child class than it is called overriding.
    2.Code associated  with a given method call is not known until the time of call at
       run time that also called dynamic binding.
    3.The argument list must be same.
    4. The return type must be same.
    5.The access modifier must not be more restrictive then the parent class method.
    6.Exception must not throw a new or broader exception.