Java For Selenium
Java For Selenium
Java For Selenium
com)
Note 2: Some features may vary from one language to another, Example:
Functions in C Languages, Methods in Java....
------------------------------------------------
Overview of Java Standard Edition / Core Java:
1) Comments
• To make the code readable
• To make the code disable from execution
Note: Java supports Single line and multiple line comments
2) Data Types:
• A Data type is a classification of the type of data that a variable or object
can hold in Computer programming
Examples:
Character,
Integer,
Float, Double....
String
Boolean etc...
Java supports two categories of Data Types,
i) Primitive Data Types
ii) Non Primitive Data Types / Reference Data Types
3) Java Modifiers
Modifiers are used to set access levels for classes, variables and methods,
Java supports two categories of Modifies
i) Access Modifiers (default, public, private, and protected)
ii) Non Access Modifiers (static, final, abstract,)
4) Java Variables
A named memory location to store or hold temporary data within a program
(RAM
ROM - HDD, CD, DVD, USB Drive etc...)
Java Supports three types of variables,
i) Local Variables
ii) Instance Variables
iii) Static Variables/Class Variables
In Java:
int a;
a=100;//Correct
b=200; //Incorrect
int c=a+b; //Incorrect
------------------------------
int a;
int a, b, c;
int d=100;
int e=200, f=300, g=400;
----------------------------
In VBScript:
Dim a
a=100 'Correct (Explicit variable)
b=200 'Correct (Implicit variable)
Msgbox a+b '300
Note: VBScript supports Implicit and Explicit declaration of variables
5) Operators in Java
Operators are used to perform Mathematical, Comparison and Logical
operations
Categories of Operators in Java,
i) Arithmetic Operators
ii) Assignment Operators
iii) Relational / Comparison Operators
iv) Logical Operators
----------------
v) Bitwise Operators
vi) Miscellaneous Operators
etc...
3) Nested Condition
if (a>b){
if (a>c){
if (a>d){
...
}
}
}
"123"
123 //Integer
"India123*&^"
Etc...
Note: Using String predefined methods we can perform operations on strings
8) Arrays
• Generally, Array is a collection of similar type of elements
Dim a, b(3)
b(0)=100
b(1) ="India"
b(2) =10.234
----------------------------
• In Java Array is an Object that contains elements of similar data types
• Java Array is index bases and index starts from zero
• The length of an Array is established when they are is created and Array
length is fixed,
• Each item in an Array is called as Element
10) Methods
What is Method?
A Set of statements to perform an Operation
Why Methods?
Methods are used for code reusability
When we choose methods?
i) Inheritance
• Inheritance is a mechanism in which one object acquires all the properties
and behaviors of parent object
• Using Inheritance we can create classes that are built-in upon existing
classes
• When we inherit from an existing class then we can reuse methods and
fields from the parent class
--------------------------
Java Supports,
a) Single Inheritance
ClassB extends ClassA
b) Mluti Level Inheritance
ClassB extends ClassA
ClassC extends ClassB
c) Multiple Inheritance (* Java doesn’t support multiple Inheritance)
ClassB extends ClassA
ClassB extends ClassZ
ii) Polymorphism
Performing task/s in different ways,
Polymorphism derived from two Greek words,
Poly - Many
Morphs - Forms / ways
So Polymorphism means "Many Ways"
Two types of Polymorphism in Java,
a) Compile Time Polymorphism / Method OverLoading
b) Run-time Polymorphism / Method Overriding
iii) Abstraction
• Abstraction is a process of hiding implementation details and showing
functionality to the user
• In another way, it shows important things to the user and hides internal
details Ex: Sending Email
• Abstraction focuses on what the object does instead of how it does
Abstraction can be achieved in two ways,
1) Abstract Class
2) Interface
iv) Encapsulation
• Encapsulation is a process of wrapping code and data together into a single
unit
Ex: Capsule
It provides control over the data
------------------------------------------------
Java Programming
Java Project
Java Package/s
Java Class/s