Showing posts with label Selenium tutorials. Show all posts
Showing posts with label Selenium tutorials. Show all posts

Friday, July 28, 2017

Java variables and its data types

This article specially deals to understand about the variables in Java and its data types. It really helpful for the Java Beginners and Selenium Freshers who want to be a professional selenium tester. First we need to try to understand what is variable ?

Generally variables are  used to store the data that may be number,character or String(group of characters). Variable can be also referred as name of the reserved area allocated in memory location.

How to declare a variable ?

 int a = 100;  // a is the variable of type Integer that holds the value 100 reserved in the RAM.

There are different types of variables available in Java. Those variables are given as below.


  1. Local variable
  2. Instance variable 
  3. Static variable

Local variable:


Variables that are declared with in methods and it will have scope with in that method


Instance variable:

Variables that are declared with in Class area but not with in methods are termed as Instance variables. It can be used by all the methods inside that class. It denotes the state of that specific class.

Static variable:

If the variables is declared as static then it can be used as local. Value of the variable can be changed only in static methods. Modification of static static variable will be reflected in the all the objects or instances using that variable.

What is meant by Datatype ?

Datatype is to denote that what type of data is going to be stored in specific variable. Two different types of datatypes are listed below.


·         primitive data types

·         non-primitive data types


Data Type
Default Value
Default size
boolean
false
1 bit
char
'\u0000'
2 byte
byte
0
1 byte
short
0
2 byte
int
0
4 byte
long
0L
8 byte
float
0.0f
4 byte
double
0.0d
8 byte







Wednesday, June 21, 2017

Java Introduction

This article is specifically deals with details of Java and its introduction. Understanding Java is more needed for working efficiently with the Automation testing tools like Selenium.


Java is created and introduced by James Gosling as programming language in 1991. Introduced company is Sun Microsystems. First version of Java is 1.0 (1995) and the latest version is 1.8 termed as Java8. Oracle acquired the company Sun Micro Systems inn year 2010. It has the general license called GPL – General public license.
Java Platform consists of below items:
1.       Programming language -  Java language has its own structure , syntax , programming paradigm and rules. It is derived from c language so the code blocks are modularized same as like { }. Structurally java starts with Namespace àProject àPackageàClasses àmethods and variables etc hierarchy.
2.       Java Compiler – Generally when we program for java platform, source code will be in .java files. During the compilation, the compiler checks against the syntax and converts/write into byte code in .Class files. These byte codes are targeted to run on JVM(java virtual machine). Java compilers differs from other compilers
3.       JVM -  During runtime, it interprets the .class files into native program instructions where CPU would interpret assembly language instructions. Difference is that JVM is software that will be specific for specific platform. – “Write Once, Run Anywhere”

Java distribution comes under two flavours
JRE – Java Run Time Environment
JDK – Java Development Kit
Difference between JDK and JRE:
1.       JRE consists of the JVM and the Java class libraries. Those contain the necessary functionality to start Java programs.
2.       JDK additionally contains the development tools necessary to create Java programs. The JDK therefore consists of a Java compiler, the Java virtual machine and the Java class libraries.

1.       Platform Independent – “Write Once and Run anywhere”
2.       Object Oriented Programming Language - Except the primitive data types, all elements in Java are objects.
3.       Strongly typed programming language -Java is strongly-typed, e.g., the types of the used variables must be pre-defined and conversion to other objects is relatively strict, e.g., must be done in most cases by the programmer.
4.       Interpreted and Compiled language - JVM
5.       Garbage Collector -Automatic garbage collection is another great feature of Java with which it prevents inadvertent corruption of memory. Similar to C++, Java has a new operator to allocate memory on the heap for a new object. But it does not use delete operator to free the memory as it is done in C++ to free the memory if the object is no longer needed. It is done automatically with garbage collector.
6.       Java supports Multithreading -Java language is that it allows multiple threads of execution to run concurrently within the same program A single Java program can have many different threads executing independently and continuously. Multiple Java applets can run on the browser at the same time sharing the CPU time.
7.       Java is distributed - extensive set of routines to handle TCP/IP protocols like HTTP and FTP java can open and access the objects across net via URLs.