The blog gives you idea of testing and automation testing example of selenium webdriver,SQl and Jmeter, you see the basic example of selenium web driver and get idea how to do automation testing,

Method Overloading In java

In a class have multiple method by same name but have different parameter, it is knows as method Overloading.

While Talking about method, it is important to know the different between two terms parameter and argument.

Parameter is a variable defined be a method that receives value when the method is called. parameter are always local to the method they dont have scope outside the method

While argument is a value that is passed to a method when it called.

package sumadding;

public class methodload {

void sum(int a, int b) {

System.out.println("Sum of two number interger number " + (a+b));
                                   }
       void sum (float a, float b)
       {
     
      System.out.println("Sum of two number interger number " + (a+b));
       }
       void sum(double d, double e) {
          {
         
          System.out.println("Sum of two number interger number " + (d+e));
          }
         
    }
     
public static void main(String[] args) {

methodload d = new methodload();
d.sum(3,8);
d.sum(4.7,6.5);
d.sum(4,98);

}

}

Sum of two Number in Java when you enter through key board

 package sumadding;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.jar.Attributes.Name;

public class sumoftwonumber {
public static void main(String[] args) throws IOException {

InputStreamReader a = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(a);

System.out.println(" ------Enter First Number ------: ");
String frist= br.readLine();
int p = Integer.parseInt(frist);

System.out.println("-------Enter Second Number--------: ");
String second= br.readLine();
int q = Integer.parseInt(second);

int c = p+q;

System.out.println("-- Sum of two Number --: " + c);

}
}

In above program InputStreamReader and BufferedReader
inputstream- This is actually read from the keyboard and store in array list.
BufferReader read the next byte of data from the  Inputstream reader.

In above Code, Frist I take input from the keyboard, user enter value from keyboard that value convert into integer,
I used Integer parsing for convert value from string to integer
same way it take second value from keyboard and store in string, using parse int I convert string into integer and after that i do addition of value and print on java console



Swapping of 2 Variable without use of third in Java

Swapping of Two variable with out using third variable, this question is asked so many times in interview,

Concept and login behind this is very simple

1) Take two variable and assign value to them
2) Add value of both variable
3) Minus value of one variable from above added variable value

Below is the code of swap variable -:

public class swapp {

static int x =10;
static int y= 20;

public static void main(String[] args)
          {
System.out.println("Value of X Before swap :-" + x );
System.out.println("Value of Y Before swap :-" + y );
x=x+y;
-- Swapping of variable logic
y=x-y;
x=x-y;
System.out.println("Value of X after swap :" + x );
System.out.println("Value of Y after swap :" + y );
}


                         }

Drop, Truncate and Delete Query for DB

Delete - Delete command is used to Remove or delete the data from the Database, Delete command delete the row from table of Database, where cause in sql and mysql  delete command is optional, it identify the row in table which we want to delete, no where cause delete all the data from the table
After Performing delete Operation you need to commit or Rollback the transaction to change the permanent or to undo, this operation will cause all the delete trigger in the table

"select count(*) from user_master"

count
-----------------------------------------
  14

"delete from user_master where name='xyz' "

3 row deleted.
----------------------------------------------
select count(*) from user_master

count
------------------------------------------
11

if you want to delete all the data from the table then execute below query

delete from user_master;

=======================================================================

Truncate  : Truncate command is used to delete all the row from the table, once you truncate then that operation can not rollback. Truncate is Faster



Truncate table tablename  - syntax
truncate table user_master;
-------------------------------------------------
table truncate
------------------------------------------
select * from user_master;
--------------------------------------
0 row
======================================================================

Drop: Drop remove the table from the Database, all the tables, index and privileges will also be removed, this operation cannot roll back. be carefully while using this command.


Syntax - Drop table tablename

drop table user_master;

Drop and Truncate are DDL(Data Definition Language) command, where as DELETE is DML( Data manipulation language). Delete command operation can be roll back(undone) while Drop and Truncate Operation cannot be rolled back.









Powered by Blogger.