Basic Java for Testers | Ch-1 | Datatypes and Variables - Software Testing

Empowering Technology

Post Top Ad

Responsive Ads Here

Mar 21, 2018

Basic Java for Testers | Ch-1 | Datatypes and Variables

Reading time: 5 minutes

Java is an essential language for Software testers as Selenium using Java is one of the best pair used in Test Automation. Here are the basics that every tester should be aware of: Let's get started with 1st Chapter Datatypes & Variables

Datatypes & Variables

In simple words, A variable is a key that holds any value till the program lifecycle. A variables's value can change as per manipulations during program execution.

A datatype defines the characteristics of a variable i.e what type of value can be stored in it.

A datatype can be Integer, String, character, float, double, boolean etc.

Note: How to name a variable? 
  1. A variable name can be a single alphabet (A-Z).
  2. Variable should start with an alphabet, ‘_’ or ‘$’ only.
  3. Variable name can include digits but cannot start with a digit
  4. The name of a variable cannot include Java keywords.

For example:

String sName = “Ishan”; 
// A String needs to be represented within Double quotes
int iNum = 10; 
// An integer can store 4 bytes. Range: -2,147,483,648 to 2,147,483, 647
boolean bResult = true; 
// Boolean datatype can store either true/false

Datatypes: String, iNum, bResult
Variables: sName , iNum, bResult 
Values: “Ishan”, 10, true

Next Chapter >>>>  Operators in Java

Sample Program to understand datatypes and variables in Java:

No comments:

Post a Comment

Thanks a lot for your valuable Comment!

Post Bottom Ad

Responsive Ads Here