Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

Data types:

The type of data which we are assigning during


run time process is a data type
Every values should be assigned with a type of
value
It can be integer, float, double, single, short, char,
string, Boolean

This data type is classified into two categories


a)Primitive data type
b) Non primitive data type

The data type which is predefined in the library is


called primitive data type
Int, float, double single short, char

Non primitive are : the type of data which we are


assigned by using reference values
Arrays, strings, oops, classes and objects
Integers: we can add two integer values
The integer value can be -ve or +Ve
It cannot be a char
It cannot be a combination of char and
values

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: collection of multiple


characters is a string or name
The string will be assigned with
double quotes
We can concatenate two strings

//string
String a="bala";
String b="krishna";
String c=a+b;
System.out.println(a +" " + b);

Non primitive data types: arrays, functions, classes


and objects, polymorphism , constructors,

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

Single if statement is used to check based on the


condition, if it true then the statement will
executes
package OPERATORS;

public class Data_types {

public static void main(String[]


args) {
// TODO Auto-generated method
stub

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;

public class Data_types {


public static void main(String[]
args) {
// TODO Auto-generated method
stub

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;

public class Data_types {


public static void main(String[]
args) {
// TODO Auto-generated method
stub

int x=10, y=20, z=30;


if((x>y)&&(x>z))
{
System.out.println("x is
greater");
}
else if((y>x)&&(y>z))
{
System.out.println("y is
greater");
}
else
{
System.out.println("z is
greater");
}

}
}

If ( condition)
If (Condition)
Statement

If condition)
If condition)
Statement

If condition
If condition
Statement

Write a program to check the greater value from


the 3 numbers

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;

public class Data_types {

public static void main(String[]


args) {
// TODO Auto-generated method
stub

int day =3;


switch(day)
{
case 1:
System.out.println("1:
monday");
break ;
case 2:
System.out.println("2:
tuesday");
break ;

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

String Browser =”Chrome”;


Switch(Browser)
{
Case 1:

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”);

Scanner sc=new scanner(System.in);


String browser;
System.out.println(‘etner the browser name”);
Browser=sc.next();
safari
System.out.println(‘the browser which u entered is :
“);
Switch(Browser)
{
Case “chrome”:
System.out.println(‘chrome browser”);
Break;

Case “safari” :
System.out.println(“ie”);
Break;
Default:
System.out.println(“invalid browser”);

You might also like