Saturday, April 4, 2015

Java programs for Selenium Interview - Class 1

Java programming examples

Example 1: Display message on computer screen.
class First {
  public static void main(String[] arguments) {
    System.out.println("Let's do something using Java technology.");
  }
}

Output of program:
Java program output
Example 2: Print integers
class Integers {
  public static void main(String[] arguments) {
    int c; //declaring a variable
 
  /* Using for loop to repeat instruction execution */
 
    for (c = 1; c <= 10; c++) {
      System.out.println(c);
    }
  }
}
Output:
10 natural numbers java program
If else control instructions:
class Condition {
  public static void main(String[] args) {
    boolean learning = true;
 
    if (learning) {
      System.out.println("Java programmer");
    }
    else {
      System.out.println("What are you doing here?");
    }
  }
}
Output:
If else java program
Command line arguments:
class Arguments {
  public static void main(String[] args) {
    for (String t: args) {
      System.out.println(t);
    }
  }
}








Command line arguments

No comments:

Post a Comment

TestNG - Can i use the 2 different data providers to same @test methods in TestNG?

public Object [][] dp1 () { return new Object [][] { new Object [] { "a" , "b" }, new Obje...