Saturday, 14 May 2016

How Big is Java ?

Frankly Saying Nothing is Big it is just a opportunity given to programmers enabling many features.

The Main IDE software that you need to install is Netbeans

The Java Compromises of Various things .These things are as follow :-


1) JDBC

--for database management etc. For this there is whole complete subject in computer Science also.

--Anyway to implement its inbuilt function you use library

import.java.sql.*

--In this case beside netbeans you also need to download sql software which is a software that runs in cmd of window.

--Also you can say it is use to connect front end with backend

2)RMI-Remote Method Invocation
--This is use for eg you have two servers in e-commerce.if you want if in one server there is deduction of Rs 10/- then the same thing should be reflected back on another server.This synchronization is achieve by RMI

--This has a server like glassfish, appache tomcat

--you can design a calculator using a RMI

--here you use library
import.java.rmi.*

3)Servelets

--In this you do XML coding .
--This is use for
         --Cookies
         --Session tracking
         --URL rewriting

4)EJB-Enterpreneur Java Beans

5)JSP-Java Server Pages

6)MVC/validator framework

7)Android

8)Struts


Some More Things that are there in java

--In class also there is a concept of class and inheritance
  here you can saee class is HelloForm and HttpServlet is the inbuilt class from which function needs to be inheritate.Note while inheritance in java you have to use keyword extends

Anyway want to learn Java [Click Here]

Wednesday, 6 April 2016

Art of Understanding an Algorithm

For Understanding the Algorithm. You first need to fascinate by its practical working.
After that Break that whole practical action into smallest step possible and Analyse each step that cause that whole magic
Try to come out from comfort zone and try till you not reach for success

Some Basic Algorithms from which you can start brushing up you skills
1) Bubble Sort
......other sorting techniques
stack
queue
circular queue
Make practical programs for all



Watch the Below Video in Silent Mode.It will give you the guidance How practically you should understand the algorithum


Sunday, 3 April 2016

Inheritance


Pointer :C/C++ brush up

int a;
&a                                  address of a
int *p                              capable of storing address of a non pointer
int **p                            capable of storing address of a pointer .this is also known as double pointer

Let us consider and code to understand above concept better


  1. int *p;
  2. int **c;
  3. int a[ ]={1,2,3,4};
  4. *p=a;                      //*p gives value of a[0] i.e 1                                  
  5. **c=&p;                 //c gives value(pointer stores address in its value) of p pointer 2293552
  6.                                //**c gives address of p pointer
  7.                                //*c --check yourself ! I don't Know
  8. printf("%u",p);       //p gives address of a[0] 2293548  
  9. *(a+i) is same as a[i]              
  10. (a+i) is same as a or &a
Notations for 2-D array


  1. //  in 1-d array you write int*p=a; but if a is 2-d array then this statement will give error
  2. int b[2][3]={ {1,2,3} , {3,4,2} };  //here b[0] occupy 8 bytes as 2 x {[0],[1],[2],[4]}=2 x 4=8 

  3. int(*p)[3]=b;       <--correct statement
  4. printf("%d",*b); / printf("%d",b[0]); / printf("%d",&b[0][0]); / printf("%d",b);printf("%d",&b[0]); <--means an address of first element.first row b[0][0]
  5. .
  6. printf("%d",*(*b+1)); <--means value at b[0][1] which is 2
  7. .
  8. Concluded: b[i][j]=*(b[i]+j) / *(*(b+i)+j) 
  9. .
  10. .

  11. printf("%d",b+1);/printf("%d",*(b+1));/printf("%d",b[1]);/printf("%d",&b[1][0]);<--means 
  12.                                                 //address of first element second row b[1][0]

  13. printf("%d",*(b+1)+2);.  //means address of b[1][2]





Notations for 3-D array




  1. int c[3][2][2]={     {{2,5},{7,9}}  , {{3,4},{6,1}} , {{0,8},{11,13}}  };
  2.  c[i][j][k]
  3. printf("%d",*c)  / printf("%d",c[0])  / printf("%d",c[0][0]) <--addr of c[0][0][0]

  4.  printf("%d",*(c[1]+1))/ / printf("%d",c[1][1])/ / printf("%d",&c[1][1][0])<--addr of c[1][1][0]
  5.                                        printf("%d",*(c[0][1]+1)) <--value of c[0][1][1];
  6. i.e c[i][j][k]= / printf("%d",*(c[i][j]+k));/printf("%d",*(*(c[i]+j)+k));/printf("%d",*(*(*(c+i)+j)+k));





Do you Know ?


  • loop pointer move by size of data type
  • scanf has &a to take value
  • printf has just a to print value
  • in array no need to write & while passing address




type specifier for printing a address--%u



Ways of Passing Array from Function: C/C++ Brush up

In programming we make a call by two methods
1)call by value- Pass a value
2)call by reference - Pass a address and fun taking this address should have pointer.And also to                                            display result again pointer.

Array is passed to a function using Call be reference.

There is Two ways

1) Using &


  1. void main( )
  2. {
  3. int a[5]={1,2,3,4,5}
  4. for(int i=0 ; i<=4 ;i++)
  5.   {
  6. printarray(&a[0]);    //or printarray(&a);[NOT SURE]
  7.    }
  8. }
  9. .
  10. .
  11. .
  12. .
  13. void printarray(int *p)
  14. {
  15. printf("%d",*p);
  16. }

2) Without Using &


  1. void main( )
  2. {
  3. int a[5]={1,2,3,4,5}

  4. printarray(a);  
  5.    
  6. }
  7. .
  8. .
  9. .
  10. .
  11. void printarray(int *p)
  12. {
  13. for(int i=0 ; i<=4 ;i++)
  14.   {
  15. printf("%d",*p);
  16.    }
  17. }
  18. }

Passing Character Array through a Function
STRING IS THE ARRAY OF CHARACTER WITH ONE NULL '\O' CHARACTER IN THE END

There is 4 ways of initilizing a character

1) 

  1. char c[4];
  2. c[0]='j'; c[1]='o'; c[2]='h'; c[3]='n'; c[4]='\0';
2)

  1. c[ ]={'j','o','h','n','\0'}
3)Using String Literal

  1. c[ ]="john";
4) Using Pointer
  1. char*c="Hellow";

  1. int main( )
  2. {
  3. char *c="Hellow";
  4. print( c)
  5. .
  6. return(0);
  7. .
  8. }
  9. .
  10. .
  11. .
  12. .
  13. ..
  14. .
  15. void print(char *c)
  16. {
  17. int i=0;
  18. while( *(c+i)!= '\0') )
  19. {
  20. printf("%c",c[i]);
  21. i++;
  22. }
  23. printf("\n");
  24. }
  25. .
  26. .//or
  27. .
  28. .
  29. .
  30. .
  31. .
  32. void print(char *c)
  33. {
  34. while( *(c)!= '\0') )
  35. {
  36. printf("%c",c[i]);
  37. c++;
  38. }
  39. printf("\n");




Passing a 2-Dimentional Array through a Function

while passing two dimensional array to function last dimension is compulsory

  1. int func (int a[ ][3])
  2. {
  3. .
  4. .
  5. .
  6. .
  7. .}
Passing a 3-Dimentional Array


  1. int func (int a[ ][2][2])  / (int (*a)[2][2])
  2. {
  3. .
  4. .
  5. .
  6. .
  7. .}

STL:Stack and queue C/C++ brush up

STL:Standard Temparary Library

In RAM and we have a stack memory !

Now in Programming we store our data in stack or queue . and we implements these
using data structure
1)Array
or
2)Link List
or
3)Trees.

all these data structures are interconnected .you can create array to queue ,queue to array

Stack

Operations on stack


  1. Push
  2. Pop
  3. Is Full
  4. Is Empty

--Exbhibit LIFO (Last in first out)
--Here in stack we have have one pointer only

  1. Top 

Push

S-our stack array
N-size of our stack array
Top-stack pointer
x-element to be pushed


  1. push(S,N,Top,x)
  2. {
  3.    if(Top+1==N)
  4.       {
  5.      printf("Stack Overflow");
  6.      exit;
  7.       }
  8. else
  9.     {
  10.       Top++;
  11.        S[Top]=x;
  12. }

Pop
--here we are only delecting the top most element of stack array S. as here we what to return the elemet which would be de;leted so for that we will use int return type of following function
  1. int pop(S,N,Top)
  2. {
  3.       int y;
  4.       if (Top==-1)
  5.         {
  6.        printf("Stack Underflow");
  7.        exit;
  8.         }
  9. else
  10.         {
  11.        y=S[Top];
  12.        Top--;
  13.        return y;
  14. }


Queue

Operations on queue


  1. Enqueue-Data Insert  <--->Push in stack
  2. Dequeue- Data Delete
  3. Is Full
  4. Is Empty


--Here in an array of queue we have two pointer

  1. front--Tells deletion
  2.  rear--Tells insertion
Enqueue
in below code
Q-Our Array
N-Size of our array
F-Front pointer of our queue
R-Rear pointer of our queue
x-element we want to put
  1. void enqueue(Q,N,F,R,x)
  2. {
  3.      if(R+1==N)  //means if R+1 ==size of an array
  4.        {
  5.         printf("Queue is overflow");
  6.         exit;
  7.         }
  8.    else if
  9.        {
  10.        if(F==R==-1)
  11.          {
  12.            F=R=0;
  13.           }
  14.         else
  15.            {
  16.             R=R+1;
  17.            }
  18. Q[R]=x;
  19. }

Dequeue

Here no x .because our aim is to just delete one element which is always from front and we also want what is the value of deleted array that's why we are returning from our function.


------------------------------------
^                             ^
Front                    Rear(insertion)
(Deletion)


  1. int dequeue(Q,N,F,R)
  2. {
  3.    int y;
  4.    if(F==R==-1)
  5.       {
  6.      prinf("underflow");
  7.      exit;
  8.      }
  9.    else
  10.      {
  11.        y=Q[F]; //delete
  12.         if (F==R)  //means in case if all element is before F is already deleted i.e null and we 
  13.                          //know after R there is nothing So , Both R & F vacant in makes no sense so
  14.                          //to get rid of that Awkward situation we are placing both in front.And
  15.                        
  16.            {
  17.               F=R=-1;
  18.             }
  19.         else
  20.           F=F+1;
  21.        return y;
  22.         }
  23. }

Typecasting C/C++ Brush up

WHEN SOME BIG SPACE DATA TRY TO INSERT IN SMALL SPACE DATATYPE THERE OCCUR'S AN ERROR SO TO REMOVE THAT ERROR WE DO TYPE CASTING.

suppose you have two datatypes let say
int a=2;                      [2 byte]  (int a=300 will be stored in meom as 00101100 00000001
float b=3.2;                [4 byte]

Now in case you write an instruction

a=b;          i.e [2 byte]<--[4 byte] then it will give error

so, for that you need to type cast above 4 byte float data type into int

i.e a=(int)b;    Now it will not give any error

Let's Here only discus the Meomory allocation in array How data will store in
int a[5]={300,301,302,20,40}

300=00000001  00101100 but in meomory  first LSB is stored then MSB
similarly 301= 00000001 00101101
i.e as 00101100 00000001  and then for 301..302..20..40


further

let i have
int a[5]={300,301,302,20,40};
int *b;
int *b=a ; /  int *b=&a;   ----OK NO ERROR
char*c;
(char*)c=a; <--NO ERROR IT WILL GIVE U ONLY 1 BYTE FROM INT.
*c=a;  ---ERROR   [1byte]<--[2byte]
*c=(char*)a;---OK,NO ERROR

float *d;
*d=a; [4 byte]<--[2byte] Ok, NO ERROR.

in arithmatic typecasting is done automatically

  1. #incude <stdio.h>
  2. #include <conio.h>

  3. int main()
  4. {
  5.     int a=20;
  6.     char k;
  7.     printf("type casted k=(char)a ");
  8.     k=(char)a;
  9.     printf("the value of k=%c\n",k);
  10.     printf("type casted a=k ");
  11.     k='a';
  12.     a=k;
  13.     printf("the value of a=%c\n",(char)a);

  14. getch();
  15. return 0;
  16. }