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



Powered by Blogger.