Professional Documents
Culture Documents
Data Types
Data Types
Example1:
//integers:
int x=10;
int y=20;
int z;
z=x+y;
System.out.println(z);
Example 2:
int x=10;
double y=20.00;
double z;
z=x+y;
System.out.println(z);
Example 3:
int x=10;
float y=20.00f;
double z;
z=x+y;
System.out.println(z);
Characters;
it will be quoted with single
it cannot be a digit
it cannot a combination of char and
integer
we cannot concatenate two char
if we want to add two char,it will
automatically converts in ascii codes
a=95
A=66
Example:
//char
char a='p';
char b='q';
int c=a+b;
System.out.println(c);
//string
String a="bala";
String b="krishna";
String c=a+b;
System.out.println(a +" " + b);
Conditional statements ;
Based on the condition the loop repeates and
terminates
If the condition is satisfied then the statement will
executes, else it will terminate
This conditional statements are of two types
a)Single if statement
b)Nested if statement
int x=10;
if(x==11)
{
System.out.println("the value of x
is :"+x);
}
If else :
If the condition is true then the first statement
will executes, else the second statement will
executes
Syntax:
If (condition)
{
Statement 1;
}
Else
{
Statmernt 2;
}
Example:
package OPERATORS;
int x=10;
int y=20;
if(x>y)
{
System.out.println("x is
greater");
}
else
{
System.out.println(" y is
greater");
}
}
Nested if statement : if with in if condition is
called nested ,we can have n no of else if
conditions with in the main if condition
Syntax”
If( condition1)
{
Statement 1;
}
Else if( condition 2)
{
Statement 2;
}
Else if (condition3)
{
Statement 3;
}
Else
{
Statement 4;
}
Example :
package OPERATORS;
}
}
If ( condition)
If (Condition)
Statement
If condition)
If condition)
Statement
If condition
If condition
Statement
Switch statement :
Switch statement allows the user to execute one
statement from many statement
Each statement will be a case in switch
If the condition is satisfied ,
Syntax;
Initialization ;
Switch(condition)
{
Case 1:
Statement1
Case 2:
Statement 2;
Case 3:
Statement 3
Case 4:
Statement 4;
Default :
Statement n;
Example :
Int i=5;
Switch(i)
{
Case 1:
Statement1
Case 2:
Statement 2;
Case 3:
Statement 3
Case 4:
Statement 4;
Default :
Statement n;
Example :
Int day=2;
Switch(day)
{
Case 1:
“Monday”;
Case 2:
“Tuesday”;
Case 3:
“Wednesday”;
Case 4:
:Thursday”;
Default :
“invalid day”;
package OPERATORS;
case 3:
System.out.println("3:
webnesday");
break;
case 4:
System.out.println("4:
thursday");
default:
System.out.println("invalid
day");
}
Cross Brower, parallel testing
System.setproperty(‘webdriver.chrome.driver”,”D://c
hromedriver.exe”);
Chromedriver d=new Chromedriver();
d.get(“http:://ww.google.com”);
d.manage(),window(),maximize();
d.close();
break;
case 2:
System.setproperty(‘webdriver.safari.driver”,”D://safa
ridriver.exe”);
Safaridriver d1=new safaridriver();
D1.get(“http:://ww.google.com”);
D1.manage(),window(),maximize();
D1.close();
Break ;
Default:
System.out.println(“invalid browser”);
Case “safari” :
System.out.println(“ie”);
Break;
Default:
System.out.println(“invalid browser”);