Selenium Class 9 - Java Operators

Similar documents
JAVA OPERATORS GENERAL

bitwise inclusive OR Logical logical AND && logical OR Ternary ternary? : Assignment assignment = += -= *= /= %= &= ^= = <<= >>= >>>=

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

Prof. Navrati Saxena TA: Rochak Sachan

Java Programming for Selenium

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

Operators Questions

Operators in java Operator operands.

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition

Java Simple Data Types

Java Programming Language. 0 A history

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;

Key Java Simple Data Types

Java Simple Data Types

Programming Basics. Digital Urban Visualization. People as Flows. ia

Zheng-Liang Lu Java Programming 45 / 79

Lecture Set 4: More About Methods and More About Operators

Chapter 3: Operators, Expressions and Type Conversion

Building Java Programs

Building Java Programs

Fall CS 101: Test 2 Name UVA ID. Grading. Page 1 / 4. Page3 / 20. Page 4 / 13. Page 5 / 10. Page 6 / 26. Page 7 / 17.

Day 2 : Intermediate Concepts 1 Examples

Building Java Programs

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following g roups:

Operators & Expressions

Operators. Java operators are classified into three categories:

CIS 1068 Program Design and Abstraction Spring2016 Midterm Exam 1. Name SOLUTION

AP COMPUTER SCIENCE A

More Things We Can Do With It! Overview. Circle Calculations. πr 2. π = More operators and expression types More statements

Motivating Examples (1.1) Selections. Motivating Examples (1.2) Learning Outcomes. EECS1022: Programming for Mobile Computing Winter 2018

Lecture 3 Operators MIT AITI

Java Review. Java Program Structure // comments about the class public class MyProgram { Variables

COSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture)

Selections. EECS1021: Object Oriented Programming: from Sensors to Actuators Winter 2019 CHEN-WEI WANG

Data and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence

The Java language has a wide variety of modifiers, including the following:

Building Java Programs. Chapter 2: Primitive Data and Definite Loops

University of Massachusetts Amherst, Electrical and Computer Engineering

DATA TYPES AND EXPRESSIONS

Object-Oriented Programming

Java Basic Programming Constructs

Some Sample AP Computer Science A Questions - Solutions

COSC 236 Section 101 Computer Science 1 -- Prof. Michael A. Soderstrand

CSC 1214: Object-Oriented Programming

CT 229. Java Syntax 26/09/2006 CT229

Lecture Set 4: More About Methods and More About Operators

CSE 201 JAVA PROGRAMMING I. Copyright 2016 by Smart Coding School

GO - OPERATORS. This tutorial will explain the arithmetic, relational, logical, bitwise, assignment and other operators one by one.

Data Types. 1 You cannot change the type of the variable after declaration. Zheng-Liang Lu Java Programming 52 / 87

More on methods and variables. Fundamentals of Computer Science Keith Vertanen

The Arithmetic Operators. Unary Operators. Relational Operators. Examples of use of ++ and

The Arithmetic Operators

CMP 326 Midterm Fall 2015

CSE 142, Spring 2009, Sample Final Exam #2. Good luck!

More types, Methods, Conditionals. ARCS Lab.

Exercises Software Development I. 05 Conversions and Promotions; Lifetime, Scope, Shadowing. November 5th, 2014

Building Java Programs Chapter 2

University of Palestine. Mid Exam Total Grade: 100

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to define and invoke void and return java methods

Java Identifiers, Data Types & Variables

Visual Programming. Lecture 2: More types, Methods, Conditionals

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

1.00 Lecture 4. Promotion

CMPS 12A - Winter 2002 Midterm 2 March 5, Name: ID:

CONTENTS: Compilation Data and Expressions COMP 202. More on Chapter 2

false, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4

Computational Expression

Building Java Programs Chapter 2. bug. Primitive Data and Definite Loops. Copyright (c) Pearson All rights reserved. Software Flaw.

Building Java Programs Chapter 2

Lara Technologies Special-Six Test

Chapter 2: Data and Expressions

Operators and Expressions

Research Group. 2: More types, Methods, Conditionals

1. Find the output of following java program. class MainClass { public static void main (String arg[])

Chapter 2 Primitive Data Types and Operations

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

Chapter 5 Control Statements: Part 2 Section 5.2 Essentials of Counter-Controlled Repetition

COMP-202: Foundations of Programming. Lecture 3: Boolean, Mathematical Expressions, and Flow Control Sandeep Manjanna, Summer 2015

Object-Oriented Programming. Topic 2: Fundamental Programming Structures in Java

CS180. Exam 1 Review

CS313D: ADVANCED PROGRAMMING LANGUAGE

Boolean Expressions. So, for example, here are the results of several simple Boolean expressions:

Place your name tag here

COMP Primitive and Class Types. Yi Hong May 14, 2015

Fundamentals of Programming CS-110. Lecture 3

5) (4 points) What is the value of the boolean variable equals after the following statement?

COMP-202 Unit 2: Java Basics. CONTENTS: Using Expressions and Variables Types Strings Methods

C212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below.

Basic computer skills such as using Windows, Internet Explorer, and Microsoft Word. Chapter 1 Introduction to Computers, Programs, and Java

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

Topic 4 Expressions and variables

Interpreted vs Compiled. Java Compile. Classes, Objects, and Methods. Hello World 10/6/2016. Python Interpreted. Java Compiled

ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 1 IDL Operators

Module - 2 Overview of Java History of Java Technology?

CMPS 11 Intermediate Programming Midterm 2 Review Problems

Perl: Arithmetic, Operator Precedence and other operators. Perl has five basic kinds of arithmetic:

CSE 142, Summer 2015

CONDITIONAL EXECUTION

Review Chapters 1 to 4. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

1. Introduction to Java for JAS

Transcription:

Selenium Class 9 - Java Operators Operators are used to perform Arithmetic, Comparison, and Logical Operations, Operators are used to perform operations on variables and values. public class JavaOperators { public static void main(string[] args) { int a=25, b=20; int c=a+b; int d=30*40; System.out.println(c);//45 System.out.println(d);//70 System.out.println(100+200);//300 System.out.println("Selenium" + " Testing");//Selenium Testing if (a>b){ System.out.println("A is a Big Number"); for (int i=1; i<=5; i++){ System.out.println(i);

//System.out.println(i);// i is local variable System.out.println(b); Categories of Operators in Java a) Arithmetic Operators b) Unary Operators c) Comparison / Relational Operators d) Logical Operators e) Assignment Operation a) Arithmetic Operators Addition, Subtraction, Multiplication, Division, Modules, Exponentiation etc... 1) Addition + (Addition, String Concatenation) int a=10, b=20; int c= a+b; //Addition

Sring d="selenium"; String e= "Testing"; String f=d+e; //Concatenation 2) Subtraction - (Subtraction, Negation) int a=10, b=20; int c= a-b; //Subtraction int d = -100; //Negation 3) Multiplication * 4) Integer Division / 5) Modules % How to conduct Exponentiation Operation? - Dawit How to conduct Division Operation? - Nathiya ----------------------------------- String + String = String Number + Number = Number String + Number = String ------------------------------------

int a=10, b=3; String c="selenium", d="testing"; System.out.println("Addition of a, b is: "+ (a+b));//addition of a, b is: 15 (Addition and Concatenation) System.out.println(a+b); //15 (Addition) System.out.println(c+d);//SeleniumTesting (Concatenation) System.out.println(a-b);//5 (Subtraction) System.out.println(a*b);//50 (Multiplication) System.out.println(a/b);//2 (Division) System.out.println(a%b);//0 b) Unary Operators The Java Unary operators require only one operand, Unary operators are used to perform various operators like increment, decrement etc... Java Unary Operators ++ -- int x=10; System.out.println(x);//10

System.out.println(x++);//10 System.out.println(x);//11 System.out.println(++x);//12 System.out.println(x--);//12 System.out.println(x);//11 System.out.println(--x);//10 for (int i=10; i>=1; i--){ System.out.println(i); Arithmetic and Unary Operators return value based result Comparison / Relational Operators return Boolean / Logical Result (true/false) c) Comparison / Relational Operators 1) == 2)!= 3) > 4) >= 5) <

6) <= int a=10, b= 20; System.out.println(a>b);//false System.out.println(a>=b);//false System.out.println(""); System.out.println(a<b);//true System.out.println(a<=b);//true System.out.println(""); System.out.println(a==b);//false System.out.println(a!=b);//true d) Logical Operators 1) Logical "Not" Operator! 2) Logical "And" Operator && 3) Logical "Or" Operator Result Criteria for "Not" Operator Expression1 Expression2 Result true true false true false true

false true true false false true Result Criteria for "And" Operator Expression1 Expression2 Result true true true true false false false true false false false false Result Criteria for "Or" Operator Expression1 Expression2 Result true true true true false true false true true false false false Example 1: boolean a=true, b=false; System.out.println(!(a&&b));//true System.out.println((a&&b));//false System.out.println(a b);//true