Sir Muhammad Naveed. Arslan Ahmed Shaad ( ) Muhammad Bilal ( )

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

JAVA OPERATORS GENERAL

Operators. Java operators are classified into three categories:

SECTION II: LANGUAGE BASICS

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

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

Chapter 3: Operators, Expressions and Type Conversion

Introduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands

Computational Expression

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

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

The Arithmetic Operators

Unit 3. Operators. School of Science and Technology INTRODUCTION

Operators in C. Staff Incharge: S.Sasirekha

Information Science 1

Operators in java Operator operands.

Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators

A flow chart is a graphical or symbolic representation of a process.

Le L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators

Instructor: SIR MUHAMMAD NAVEED Created by: ARSLAN AHMED SHAAD ( ) MUHAMMAD BILAL ( ) ISIT:

Department of Computer Science

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

Java Primer 1: Types, Classes and Operators

CSC 1214: Object-Oriented Programming

Basics of Java Programming

CS313D: ADVANCED PROGRAMMING LANGUAGE

Chapter 2 Working with Data Types and Operators

Operators and Expressions

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

3. Java - Language Constructs I

Programming in C++ 5. Integral data types

Introduction to Programming Using Java (98-388)

Operators & Expressions

Java Notes. 10th ICSE. Saravanan Ganesh

Module 2 - Part 2 DATA TYPES AND EXPRESSIONS 1/15/19 CSE 1321 MODULE 2 1

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

Expressions. Arithmetic expressions. Logical expressions. Assignment expression. n Variables and constants linked with operators

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

A complex expression to evaluate we need to reduce it to a series of simple expressions. E.g * 7 =>2+ 35 => 37. E.g.

Data Types and Variables in C language

Full file at

Programming with Java

Basics of Programming

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

Fundamentals of Programming CS-110. Lecture 3

Object-Oriented Programming

CT 229. Java Syntax 26/09/2006 CT229

UNIT- 3 Introduction to C++

CSCI 2010 Principles of Computer Science. Data and Expressions 08/09/2013 CSCI

Chapter 4: Basic C Operators

Information Science 1

Operators and Expressions:

More Programming Constructs -- Introduction

Java Basic Programming Constructs

Chapter 2: Using Data

Operators. Lecture 3 COP 3014 Spring January 16, 2018

Declaration and Memory

I Internal Examination Sept Class: - BCA I Subject: - Principles of Programming Lang. (BCA 104) MM: 40 Set: A Time: 1 ½ Hrs.

DEPARTMENT OF MATHS, MJ COLLEGE

Program Fundamentals

Unit-2 (Operators) ANAND KR.SRIVASTAVA

Visual C# Instructor s Manual Table of Contents

Data and Expressions. Outline. Data and Expressions 12/18/2010. Let's explore some other fundamental programming concepts. Chapter 2 focuses on:

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

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

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Operators And Expressions

Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur

Client-Side Web Technologies. JavaScript Part I

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

Chapter 7. Expressions and Assignment Statements ISBN

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Fundamentals of Programming

Prof. Navrati Saxena TA: Rochak Sachan

Outline. Performing Computations. Outline (cont) Expressions in C. Some Expression Formats. Types for Operands

Sprite an animation manipulation language Language Reference Manual

Objects and Types. COMS W1007 Introduction to Computer Science. Christopher Conway 29 May 2003

A Java program contains at least one class definition.

CMPT 125: Lecture 3 Data and Expressions

Chapter 1 Introduction to java

Expressions and Precedence. Last updated 12/10/18

Introduction to Programming (Java) 2/12

JAVA Programming Fundamentals

Fundamental of Programming (C)

LECTURE 3 C++ Basics Part 2

Expressions & Assignment Statements

Data Types, Literals, Operators

Lexical Considerations

4. Inputting data or messages to a function is called passing data to the function.

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

ISA 563 : Fundamentals of Systems Programming

A variable is a name for a location in memory A variable must be declared

DaMPL. Language Reference Manual. Henrique Grando

Index COPYRIGHTED MATERIAL

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

SOFTWARE DEVELOPMENT 1. Operators 2018W A. Ferscha (Institute of Pervasive Computing, JKU Linz)

COMP 202 Java in one week

VARIABLES & ASSIGNMENTS

COMP 110 Introduction to Programming. What did we discuss?

Slide 1 CS 170 Java Programming 1 Expressions Duration: 00:00:41 Advance mode: Auto

Transcription:

Sir Muhammad Naveed Arslan Ahmed Shaad (1163135 ) Muhammad Bilal ( 1163122 ) www.techo786.wordpress.com

CHAPTER: 2 NOTES:- VARIABLES AND OPERATORS The given Questions can also be attempted as Long Questions. Q1: What is the syntax of java? Syntax of java include White space Identifier Comment Literals Keyword Operator Q2: Define and explain identifier? In programming languages, identifiers are used for identification purpose. In Java an identifier can be a class name, method name, variable name or a label. Identifier must follow some rules. Here are the rules: All identifiers must start with either a letter (a to z or A to Z) or currency character ($) or an underscore. After the first character, an identifier can have any combination of characters. A Java keyword cannot be used as an identifier. Identifiers in Java are case sensitive, foo and Foo are two different identifiers. In the HelloWorld program, HelloWorld, String, args, main and println are identifiers.

Q3: What are comments? In java comments are statements that are not executed by the compiler and interpreter. The comments can be used to provide information or explanation about the variable, method, class or any statement. It can also be used to hide program code for specific time. There are three types of comments Single line comment Multi-line comment Documentation Q4: Define literals? Java Literals are syntactic representations of Boolean, character, numeric, or string data. Literals provide a means of expressing specific values in your program. Example: // here 100 is a constant literal Int x= 100; Q5: Define keyword? Keyword is a special purpose word in a programming language that has a predefined meaning. Programmers cannot use keywords as names for variables, methods, classes, or as any other identifier. Abstract, class, Etc. are keywords Q6: Define operator and it s types? Operators are special symbols that perform specific operations on one, two, or three operands, and then return a result. Types of operators: Arithmetic operator Shift operator Relational operator Bitwise operator Logical operator

Unary operator Ternary operator Assignment operator Q7: Define arithmetic operator? Arithmetic operators are used in mathematical expressions in the same way that they are used in algebra Q8: Define relational operator? A relational operator compares two values and determines the relationship between them. Output of relation operator is always a Boolean value. They are often used in branches and loop control. The relational operator are given below

Q9: Define logical operator? A logical operator (sometimes called a Boolean operator ) in Java programming is an operator that returns a Boolean result that's based on the Boolean result of one or two other expressions. Q10: Define bitwise operator? The operator which operates expression bit by bit is called bitwise operator. Q11: Define increment operator? Increment operator is represented by a double plus (++) sign. It is used to add 1 to the value of a variable.

Q12: Define decrement operator? The decrement operator is represented by double minus ( ). it is used to minus 1 from the value of a variable Q13: What is prefix operator? When the increment operator is written before the variable name it is known as prefix operator.it first add 1 to the value of variable and then the value of variable is used in the expression. E.g. ++a Q14: What is postfix operator? When an increment operator is written after the variable name, it is known as postfix operator. It first use the current value of the postfix variable in the expression and then add 1 to the value of the variable. E.g. a++ Q15: What is prefix decrement operator? When the decrement operator is written before the variable name it is known as prefix decrement operator.it first subtract 1 from the value of variable and then the value of variable is used in the expression. E.g. a Q16: Define postfix decrement operator? When the decrement operator is written after the variable name it is known as postfix decrement operator. It first use the current value of the postfix variable in the expression and then subtract 1 from the value of the variable. E.g. a Q17: Define assignment operator? Operator which is to assign a value to the variable is called assignment operator. It is a binary operator. Syntax: variable = exp

Q18: Define unary operator? The operator that need only one data item to operate on are called unary operator Q19: What is ternary operator? Ternary operator is shorthand for if else statement. Syntax = expression? exp 1 : exp 2 ; Example = int febdays = 29; String result; result= if( febdays = = 29)? leap year : not leap year ; System.out.println(result); Q20: Define shift operator? These operators are used to shift values to left or right. E.g. left shift = multiply << Right shift = division >> Q21: What is modulus operator? The modulus operator return the reminder of division operator.

Operator precedence determines the order in which the operators in an expression are evaluated A quantity whose value may change during execution of program is called variable. It may be numeric or a nun numeric value. It is represented by an identifier called variable name

White space are not allowed in variable names. Must start with a letter, underscore ( _ ) or dollar sign ($ ). After first letter you may use any letter number or symbol. Java is case sensitive ( apple & APPLE are not same ). Every new word in a variable name will start with capital letter. There are three types of variable. Local variable Instance variable Static variable Local variable are declared inside the method, constructor or blocks. Local variable has no default value. Local variable are created when the method, constructor or block is entered, and destroyed when its exist the constructor, method or block of code. Instance variable are declared inside the class but outside the method, constructor or block Instance variable are created with new () and destroyed when object is destroyed. Instance variable has default value.

A variable that is declares static is called static variable. This type of variable are initialized only once in a program. Auto boxing is an automatic conversion from primitive data type to the corresponding wrapper classes. Primitive Int wrapper integer Conversion of wrapper classes object into fundamental data type is called unboxing. e.g. integer i = new integer (55); int a = i ; Thank You for visiting www.vbforstudent.tk Go to this link for new updates on technology: www.techo786.wordpress.com