SlideShare a Scribd company logo
1 of 74
Download to read offline
Java Programming 
Semester- V 
Course: CO/CM/IF 
Tushar B Kute, 
Assistant Professor, 
Sandip Institute of Technology and Research Centre, Nashik.
Contents 
● Java Features and the Java Programming 
Environment. 
● Java Tokens & Data types 
● Operators & Expressions 
● Decision making & looping
Features of Java 
● Object Oriented 
● Compiled 
● Interpreted 
● Platform independent 
● Portable 
● Robust and Secure 
● Dynamic.
How Java Works[1] 
Source code 
Java Compiler 
bytecode 
Windows 
interpreter 
Linux 
interpreter 
MacOs 
interpreter 
Solaris 
interpreter 
Machine code Machine code Machine code Machine code 
Windows 
Computer 
Linux 
Computer 
MacOs 
Computer 
Solaris 
Computer
Java Compiler 
Java program Java compiler Virtual Machine 
Source code
Java Interpreter 
bytecode Java Interpreter Machine code 
Virtual Machine Real Machine
A Java Program 
Documentation Section 
Package Statements 
Import Statements 
Interface Statements 
Class Definitions 
main method class 
{ 
main method definition 
}
Java Tokens and Data Types 
● Constants & Symbolic Constants, 
● Variables 
● Dynamic initialization 
● Data types 
● Array & string 
● Scope of variable 
● Type casting, 
● Standard default values.
Java Tokens 
● Identifiers 
● Keywords 
● Literals 
● Operators 
● Separators
Forming a Java Program 
Alphabets, 
Digits, 
Special 
Symbols 
Constants, 
Variables, 
And 
Keywords 
Instructions Program 
Tokens
Constants 
Constants 
Numeric 
Constants 
Character 
Constants 
Floating point 
Constants 
Character 
Constants 
Integer 
Constants 
String 
Constants 
Boolean 
Constants
Identifiers 
Identifiers are the programmer-designed tokens. They are used 
for naming variables, classes, methods, objects, labels, 
packages and interfaces in a program. In order to give the name 
for the identifiers, we have to follow following rules: 
● They can have only alphabets, digits, underscore ( _ ) and 
dollar sign ( $ ) characters. 
● They must not begin with digit. Digit can be placed anywhere 
except staring position. 
● Uppercase and lowercase letters are different. 
● They can be of any length. 
● They must not be the keywords. 
● They can have any special symbol in it.
Variables 
A variable is an identifier that denotes a storage location used to 
store the data value. Unlike constants that may remain unchanged 
during execution of the program, a variable may take different values 
at different times during execution of program. A variable name is 
chosen by the programmer in meaningful way so as to reflect what it 
represents in the program. 
Example: 
total_marks 
calci 
average 
inventory
Data types 
Data Types 
Primitive Derived 
Numeric Non -numeric Class Array Interface 
Integer Real Character Boolean
Integer 
Type Size Minimum Value Maximum Value 
byte One byte -128 127 
short Two bytes -32,768 32,767 
int Four bytes -2,147,483,648 2,147,483,647 
long Eight bytes -9,223,372,036,854,775,808 9,223,372,036,854,775,807
Real 
Type Size Minimum Value Maximum Value 
float Four bytes 3.4e–38 3.4e+38 
double Eight bytes 1.7e–308 1.7e+308
Character 
In order to store single character constant in a 
variable, character data type is used. Like C/C++, 
the keyword char is used to declare character 
data type variable. Two bytes are required to store 
a single character in memory. Because, the 
characters in Java use Unicode system, in which 
each character is represented by 16 bits i.e. 2 
bytes. All characters in Unicode can be stored in a 
character data type variable.
Boolean 
This is one of the most useful data types of Java. 
Like bool data type of C++, Boolean data type is 
used to store two different values. But, values stored 
inside the boolean type will only be true and false. It 
can not have values like 0 or 1. It is used in program 
to test a particular condition during the execution. 
Boolean is denoted by keyword boolean and uses 
only one bit of storage. All relational operators (i.e. 
comparison operators like <, > etc.) return these 
boolean values.
Standard default values 
Type of variable Default value 
boolean false 
byte zero : 0 
short zero : 0 
int zero : 0 
long zero : 0L 
float 0.0f 
double 0.0d 
char null character 
reference null
Scope of variables 
Basically, the Java variables are categorized into 
three types: 
● Instance variables 
● Local variables
Scope of the variables 
According to the types of variables, the scopes 
of the Java program have following types: 
● Block scope 
● Class scope
Block scope
Operators and expressions 
● Arithmetic Operators, Relational Operators, Logical 
Operators, Increment & Decrement, Conditional 
Operators, Bit wise Operators, Instance of 
Operators, Dot Operators, Operator 
● Precedence & associativity 
● Evaluation of Expressions 
● Type conversions in expressions 
● Mathematical Functions – min(), max(), sqrt(), pow(), 
exp(), round(), abs().
Operators 
● Arithmetic Operators 
● Assignment Operators 
● Increment / Decrement Operators 
● Relational Operators 
● Logical Operators 
● Conditional Operators 
● Special Operators
Arithmetic operators 
Operator Meaning Example 
+ Addition 9 + 45 
– Subtraction 89 – 12 
* Multiplication 10 * 3 
/ Division 18 / 6 
% Modulo Division 14 % 3 
+ Unary Plus +51 
– Unary Minus –92
Relational operators 
Operator Meaning 
< Less than 
> Greater than 
<= Less than or equal to 
>= Greater than or equal to 
== Equal to 
!= Not equal to
Logical operators 
Operator Meaning 
&& Logical AND 
|| Logical OR 
! Logical NOT
Increment-Decrement 
Like C and C++, Java is also having the increment and 
decrement operators’ i.e. 
++ and –– 
Both of these are unary operators. The operator ++ adds 1 to 
the operand and – – subtracts 1 from the operand. They are 
only associated with the variable name, not with the constant 
or the expression. They can be written in following from: 
x++ or x—- 
++x or --x
Conditional 
The only ternary operator (operator having three 
operands) is defined in Java called as conditional 
operator. The character pair ? : is termed as 
conditional operator. This is used to construct the 
conditional expression of the following form: 
condition ? expression2 : expression3
Bitwise operators 
Operator Meaning 
& Bitwise AND 
| Bitwise OR 
^ Bitwise EX-OR 
~ One’s complement 
<< Left shift 
>> Right shift 
>>> Right shift with zero fill
instanceof 
instanceof is the keyword called as an object 
reference binary operator. It returns true if the 
object on the left-hand side is an instance or 
object of the class given on the right-hand side. 
This operator allows us to determine whether the 
object belong to particular class or not. 
For example: 
maharashtra instanceof India
Dot operator 
This is also called as dot operator (.). It is used to 
access the instance variable and methods of the 
class using objects. 
For example: 
company.salary() //reference to method salary 
company.employee //reference to variable employee
Precedence and Associativity 
When the expression involves more than one 
operation, then which operation is to be performed 
first is decided by the precedence of that operator. 
Highest precedence operation is solved first. Each 
operator of Java has precedence associated with 
it. The operators with the same precedence are 
evaluated according to there associativity. That is, 
the expression is evaluated either from left to right 
or right tot left.
Precedenc 
e 
Operator Description Associati 
on 
1 . Member selection L to R 
() Function call L to R 
[] Array element reference L to R 
2 ++,-- Postincrement, 
Postdecrement 
R to L 
3 ++,-- Preincrement, 
Predecrement 
R to L 
+,- Unary plus, unary minus R to L 
~ Bitwise compliment R to L 
! Boolean NOT R to L 
4 new Create object R to L 
(type) Type cast R to L 
5 *,/,% Multiplication, division, 
remainder 
L to R 
6 +,- Addition, subtraction L to R 
+ String concatenation L to R
7 <<, >>, >>> Shift operators L to R 
8 <, <=, >, >= Less than, less than or 
equal to, greater than, 
greater than or equal to 
L to R 
instanceof Type comparison L to R 
9 ==, != Value equality and 
inequality 
L to R 
==, != Reference equality and 
inequality 
L to R 
10 & Boolean AND L to R 
& Bitwise AND L to R
11 ^ Boolean XOR L to R 
^ Bitwise XOR L to R 
12 | Boolean OR L to R 
| Bitwise OR L to R 
13 && Conditional AND L to R 
14 || Conditional OR L to R 
15 ?: Conditional Ternary 
Operator 
L to R 
16 =,+=,-=, 
*=,/ =, 
%=,&=,^=, | 
=, <<=, >> 
=, >>>= 
Assignment Operators R to L
Automatic type conversion 
char byte short int long float double 
char int int int int long float double 
byte int int int int long float double 
short int int int int long float double 
int int int int int long float double 
long long long long long long float double 
float float float float float float float double 
doubl 
e 
double double double double double double double
Type promotions rules 
● All byte, short and char values are promoted to 
int. 
● If one operand in the expression is long then the 
whole expression will be promoted to long. 
● If one operand is float then the whole 
expression will be promoted to float. 
● If any of the operands is double, the result is 
double.
Type casting 
In automatic type conversion always lower type is 
converted to higher type. If we want to convert higher 
type to lower type then type casting is necessary. For 
that purpose the type casting operator is used. 
This type of conversion is called as narrowing the 
conversion. It takes the following form. 
(target_type) variable_name;
Example: 
class Casting 
{ 
public static void main(String args[]) 
{ 
byte b; 
int val = 163; 
b = (byte) val; 
System.out.println(b); 
} 
}
Symbolic constants 
Same way if we want to define the constant in 
Java one type modifier is used called final. ‘final’ is 
the keyword used to define the symbolic constant 
in a Java program. It takes the following form: 
final data_type variable_name = value; 
Example: final double Pi = 3.145;
Decision making and looping 
● if statement 
● if-else statement 
● switch-case statement 
● Conditional operator statement
if statement 
if (condition) 
statement; 
or 
if (condition) 
{ 
statement1; 
statement2; 
statement3; 
}
If statement 
Entry 
condition 
true 
Statements under ‘if’ 
statement 
Statements after ‘if’ 
statement 
false
Example: 
1.if(number < 0) 
System.out.println(“The number is negative”); 
2.if(ch > ‘A’ && ch < ‘Z’) 
System.out.println(“It is upper case 
letter”); 
3.if(sell_price > cost_price) 
System.out.println(“You made profit”);
Nested-if 
if(condition1) 
if(condition2) 
statement;
Nested-if 
if(condition1) 
if(condition2) 
{ 
statement1; 
statement2; 
statement3; 
}
if-else statement 
if(condition) 
{ 
statements for condition is true; 
} 
else 
{ 
statements for condition is false; 
} 
Statements after the blocks;
If-else
Nested if-else
If-else ladder 
if(condition1) 
statement1; 
else 
if(condition2) 
statement2; 
else 
if(condition3) 
statement3; 
else 
statement4;
Example: 
if(marks>=75) 
grade = “distinction”; 
else 
if(marks >= 60) 
grade = “First class”; 
else 
if(marks >= 50) 
grade = “Second class”; 
else 
if(marks >= 40) 
grade = “Pass class”; 
else 
grade = “fail”;
The switch statement 
switch(variable) 
{ 
case value-1: 
statements-1; 
break; 
case value-2: 
statements-2; 
break; 
- - - - - - - - - 
- - - - - - - - - 
default: 
default block; 
} 
statement-out;
The switch statement
Example: 
class NumDisplay 
{ 
public static void main(String args[]) 
{ 
int x = 6; 
System.out.println("x = "+x); 
System.out.print("It is "); 
switch(x) 
{ 
case 1: System.out.println("One"); 
break; 
case 2: System.out.println("Two"); 
break; 
default: System.out.println("No. not correct"); 
} 
} 
}
The while loop 
Initialization; 
while (condition) 
{ 
//body of the loop; 
}
Example: 
int i = 0; 
while(i<10) 
{ 
System.out.println(“I Love Java”); 
I++; 
}
The while loop
The do-while loop 
do 
{ 
//body of the loop; 
} 
while(condition);
The do-while loop
Example: 
int a = 0; 
do 
{ 
System.out.println(“I Love Java”); 
a++; 
} 
while(a<10);
The for loop 
for(initialization ; condition ; increment/decrement) 
{ 
Body of the loop; 
}
The for loop
The for loop 
for(a = 0; a < 10; a++ ) 
{ 
System.out.println(a); 
}
Comparison 
while do-while for 
x = 0; 
while(x<10) 
{ 
-------; 
-------; 
x++; 
} 
x = 0; 
do 
{ 
-------; 
-------; 
x++; 
} 
while(x<10); 
for(x=0;x<10; 
x++) 
{ 
-------; 
-------; 
}
Nesting of loops 
for(int x = 0;x<10;x++) 
{ 
y = 0; 
while(y<10) 
{ 
------; 
------; 
} 
} 
-------; 
-------;
The break statement 
while(condition) 
{ 
------; 
------; 
if(condition) 
break; 
------; 
------; 
} 
------;
Labeled break or labeled loop 
The general form of the labeled break statement 
is, 
break label;
Example: 
class BreakNested 
{ 
public static void main(String args[]) 
{ 
outer: 
for(int x=0;x<10;x++) 
{ 
System.out.print("This is "+x+": "); 
for(int y=0;y<10;y++) 
{ 
if(y==5) 
break outer; 
System.out.print(" "+y+" "); 
} 
} 
System.out.println("Program finished..."); 
} 
}
The continue statement 
It is useful to force the early iteration of the loop. 
When we want to continue the next iteration of the 
loop by skipping some part inside it, the ‘continue’ 
statement can be used. It is also associated with 
the condition. General form of the ‘continue’ is: 
continue;
The continue statement
Example: 
class ContinueDemo 
{ 
public static void main(String args[]) 
{ 
for(int i=0; i<10; i++) 
{ 
if (i%2 == 0) 
continue; 
System.out.println(i + " "); 
} 
} 
}
References
Thank you 
This presentation is created using LibreOffice Impress 4.2.6.3 and 
available freely under GNU GPL

More Related Content

What's hot

Software engineering tutorial
Software engineering tutorial Software engineering tutorial
Software engineering tutorial Ahmed Elshal
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Languagejaimefrozr
 
Java basics and java variables
Java basics and java variablesJava basics and java variables
Java basics and java variablesPushpendra Tyagi
 
Data types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaData types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaJaved Rashid
 
2- THE CHANGING NATURE OF SOFTWARE.pdf
2- THE CHANGING NATURE OF SOFTWARE.pdf2- THE CHANGING NATURE OF SOFTWARE.pdf
2- THE CHANGING NATURE OF SOFTWARE.pdfbcanawakadalcollege
 
Introduction to Software Engineering
Introduction to Software EngineeringIntroduction to Software Engineering
Introduction to Software EngineeringSaqib Raza
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in javaTech_MX
 
Characteristics of OOPS
Characteristics of OOPS Characteristics of OOPS
Characteristics of OOPS abhishek kumar
 
Trojan virus & backdoors
Trojan virus & backdoorsTrojan virus & backdoors
Trojan virus & backdoorsShrey Vyas
 
Web Application Deployment
Web Application DeploymentWeb Application Deployment
Web Application Deploymentelliando dias
 
Basics of JAVA programming
Basics of JAVA programmingBasics of JAVA programming
Basics of JAVA programmingElizabeth Thomas
 
Unit 1 - Introduction to Software Engineering.ppt
Unit 1 - Introduction to Software Engineering.pptUnit 1 - Introduction to Software Engineering.ppt
Unit 1 - Introduction to Software Engineering.pptDrTThendralCompSci
 
Difference between C++ and Java
Difference between C++ and JavaDifference between C++ and Java
Difference between C++ and JavaAjmal Ak
 
Best Cyber Security Projects | The Knowledge Academy
Best Cyber Security Projects | The Knowledge Academy Best Cyber Security Projects | The Knowledge Academy
Best Cyber Security Projects | The Knowledge Academy The Knowledge Academy
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming languageMd.Al-imran Roton
 

What's hot (20)

Software engineering tutorial
Software engineering tutorial Software engineering tutorial
Software engineering tutorial
 
CSharp.ppt
CSharp.pptCSharp.ppt
CSharp.ppt
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
 
Java basics and java variables
Java basics and java variablesJava basics and java variables
Java basics and java variables
 
Data types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaData types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in java
 
2- THE CHANGING NATURE OF SOFTWARE.pdf
2- THE CHANGING NATURE OF SOFTWARE.pdf2- THE CHANGING NATURE OF SOFTWARE.pdf
2- THE CHANGING NATURE OF SOFTWARE.pdf
 
Deep learning presentation
Deep learning presentationDeep learning presentation
Deep learning presentation
 
Introduction to Software Engineering
Introduction to Software EngineeringIntroduction to Software Engineering
Introduction to Software Engineering
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Next word Prediction
Next word PredictionNext word Prediction
Next word Prediction
 
Characteristics of OOPS
Characteristics of OOPS Characteristics of OOPS
Characteristics of OOPS
 
Trojan virus & backdoors
Trojan virus & backdoorsTrojan virus & backdoors
Trojan virus & backdoors
 
Web Application Deployment
Web Application DeploymentWeb Application Deployment
Web Application Deployment
 
Basics of JAVA programming
Basics of JAVA programmingBasics of JAVA programming
Basics of JAVA programming
 
Unit 1 - Introduction to Software Engineering.ppt
Unit 1 - Introduction to Software Engineering.pptUnit 1 - Introduction to Software Engineering.ppt
Unit 1 - Introduction to Software Engineering.ppt
 
Difference between C++ and Java
Difference between C++ and JavaDifference between C++ and Java
Difference between C++ and Java
 
Python for Data Science
Python for Data SciencePython for Data Science
Python for Data Science
 
Best Cyber Security Projects | The Knowledge Academy
Best Cyber Security Projects | The Knowledge Academy Best Cyber Security Projects | The Knowledge Academy
Best Cyber Security Projects | The Knowledge Academy
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming language
 
Java Applets
Java AppletsJava Applets
Java Applets
 

Viewers also liked

Java essentials for hadoop
Java essentials for hadoopJava essentials for hadoop
Java essentials for hadoopSeo Gyansha
 
Security Architecture of the Java Platform (http://www.javaday.bg event - 14....
Security Architecture of the Java Platform (http://www.javaday.bg event - 14....Security Architecture of the Java Platform (http://www.javaday.bg event - 14....
Security Architecture of the Java Platform (http://www.javaday.bg event - 14....Martin Toshev
 
Security Architecture of the Java platform
Security Architecture of the Java platformSecurity Architecture of the Java platform
Security Architecture of the Java platformMartin Toshev
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in JavaTushar B Kute
 

Viewers also liked (10)

Java essentials for hadoop
Java essentials for hadoopJava essentials for hadoop
Java essentials for hadoop
 
JAVA PROGRAMMING
JAVA PROGRAMMING JAVA PROGRAMMING
JAVA PROGRAMMING
 
Type casting
Type castingType casting
Type casting
 
Security Architecture of the Java Platform (http://www.javaday.bg event - 14....
Security Architecture of the Java Platform (http://www.javaday.bg event - 14....Security Architecture of the Java Platform (http://www.javaday.bg event - 14....
Security Architecture of the Java Platform (http://www.javaday.bg event - 14....
 
Basics of c++
Basics of c++Basics of c++
Basics of c++
 
Security Architecture of the Java platform
Security Architecture of the Java platformSecurity Architecture of the Java platform
Security Architecture of the Java platform
 
Core java course syllabus
Core java course syllabusCore java course syllabus
Core java course syllabus
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
Control statements
Control statementsControl statements
Control statements
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 

Similar to Chapter 01 Introduction to Java by Tushar B Kute

Java: Primitive Data Types
Java: Primitive Data TypesJava: Primitive Data Types
Java: Primitive Data TypesTareq Hasan
 
Data Types, Variables, and Operators
Data Types, Variables, and OperatorsData Types, Variables, and Operators
Data Types, Variables, and OperatorsMarwa Ali Eissa
 
Introduction to golang
Introduction to golangIntroduction to golang
Introduction to golangwww.ixxo.io
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming FundamentalsHassan293
 
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Jitendra Bafna
 
C sharp part 001
C sharp part 001C sharp part 001
C sharp part 001Ralph Weber
 
Introduction to c
Introduction to cIntroduction to c
Introduction to cAjeet Kumar
 
M.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C LanguageM.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C LanguageDr.Florence Dayana
 
UNIT II_python Programming_aditya College
UNIT II_python Programming_aditya CollegeUNIT II_python Programming_aditya College
UNIT II_python Programming_aditya CollegeRamanamurthy Banda
 
chapter-1-review-of-python-basics-copy.pdf
chapter-1-review-of-python-basics-copy.pdfchapter-1-review-of-python-basics-copy.pdf
chapter-1-review-of-python-basics-copy.pdfSangeethManojKumar
 
OCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & StatementsOCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & Statementsİbrahim Kürce
 

Similar to Chapter 01 Introduction to Java by Tushar B Kute (20)

Java: Primitive Data Types
Java: Primitive Data TypesJava: Primitive Data Types
Java: Primitive Data Types
 
Data Types, Variables, and Operators
Data Types, Variables, and OperatorsData Types, Variables, and Operators
Data Types, Variables, and Operators
 
unit1 python.pptx
unit1 python.pptxunit1 python.pptx
unit1 python.pptx
 
Introduction to golang
Introduction to golangIntroduction to golang
Introduction to golang
 
Guide to Java.pptx
Guide to Java.pptxGuide to Java.pptx
Guide to Java.pptx
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
 
Basic
BasicBasic
Basic
 
Java chapter 2
Java chapter 2Java chapter 2
Java chapter 2
 
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
 
C sharp part 001
C sharp part 001C sharp part 001
C sharp part 001
 
JAVASCRIPT - LinkedIn
JAVASCRIPT - LinkedInJAVASCRIPT - LinkedIn
JAVASCRIPT - LinkedIn
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
 
M.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C LanguageM.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C Language
 
C Language Part 1
C Language Part 1C Language Part 1
C Language Part 1
 
UNIT II_python Programming_aditya College
UNIT II_python Programming_aditya CollegeUNIT II_python Programming_aditya College
UNIT II_python Programming_aditya College
 
Basic concept of c++
Basic concept of c++Basic concept of c++
Basic concept of c++
 
chapter-1-review-of-python-basics-copy.pdf
chapter-1-review-of-python-basics-copy.pdfchapter-1-review-of-python-basics-copy.pdf
chapter-1-review-of-python-basics-copy.pdf
 
OCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & StatementsOCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & Statements
 
C basics
C basicsC basics
C basics
 
C basics
C basicsC basics
C basics
 

More from Tushar B Kute

Apache Pig: A big data processor
Apache Pig: A big data processorApache Pig: A big data processor
Apache Pig: A big data processorTushar B Kute
 
01 Introduction to Android
01 Introduction to Android01 Introduction to Android
01 Introduction to AndroidTushar B Kute
 
Ubuntu OS and it's Flavours
Ubuntu OS and it's FlavoursUbuntu OS and it's Flavours
Ubuntu OS and it's FlavoursTushar B Kute
 
Install Drupal in Ubuntu by Tushar B. Kute
Install Drupal in Ubuntu by Tushar B. KuteInstall Drupal in Ubuntu by Tushar B. Kute
Install Drupal in Ubuntu by Tushar B. KuteTushar B Kute
 
Install Wordpress in Ubuntu Linux by Tushar B. Kute
Install Wordpress in Ubuntu Linux by Tushar B. KuteInstall Wordpress in Ubuntu Linux by Tushar B. Kute
Install Wordpress in Ubuntu Linux by Tushar B. KuteTushar B Kute
 
Share File easily between computers using sftp
Share File easily between computers using sftpShare File easily between computers using sftp
Share File easily between computers using sftpTushar B Kute
 
Signal Handling in Linux
Signal Handling in LinuxSignal Handling in Linux
Signal Handling in LinuxTushar B Kute
 
Implementation of FIFO in Linux
Implementation of FIFO in LinuxImplementation of FIFO in Linux
Implementation of FIFO in LinuxTushar B Kute
 
Implementation of Pipe in Linux
Implementation of Pipe in LinuxImplementation of Pipe in Linux
Implementation of Pipe in LinuxTushar B Kute
 
Basic Multithreading using Posix Threads
Basic Multithreading using Posix ThreadsBasic Multithreading using Posix Threads
Basic Multithreading using Posix ThreadsTushar B Kute
 
Part 04 Creating a System Call in Linux
Part 04 Creating a System Call in LinuxPart 04 Creating a System Call in Linux
Part 04 Creating a System Call in LinuxTushar B Kute
 
Part 03 File System Implementation in Linux
Part 03 File System Implementation in LinuxPart 03 File System Implementation in Linux
Part 03 File System Implementation in LinuxTushar B Kute
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingTushar B Kute
 
Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)Tushar B Kute
 
Open source applications softwares
Open source applications softwaresOpen source applications softwares
Open source applications softwaresTushar B Kute
 
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)Introduction to Ubuntu Edge Operating System (Ubuntu Touch)
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)Tushar B Kute
 
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B KuteUnit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B KuteTushar B Kute
 
Technical blog by Engineering Students of Sandip Foundation, itsitrc
Technical blog by Engineering Students of Sandip Foundation, itsitrcTechnical blog by Engineering Students of Sandip Foundation, itsitrc
Technical blog by Engineering Students of Sandip Foundation, itsitrcTushar B Kute
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteTushar B Kute
 
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteJava Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteTushar B Kute
 

More from Tushar B Kute (20)

Apache Pig: A big data processor
Apache Pig: A big data processorApache Pig: A big data processor
Apache Pig: A big data processor
 
01 Introduction to Android
01 Introduction to Android01 Introduction to Android
01 Introduction to Android
 
Ubuntu OS and it's Flavours
Ubuntu OS and it's FlavoursUbuntu OS and it's Flavours
Ubuntu OS and it's Flavours
 
Install Drupal in Ubuntu by Tushar B. Kute
Install Drupal in Ubuntu by Tushar B. KuteInstall Drupal in Ubuntu by Tushar B. Kute
Install Drupal in Ubuntu by Tushar B. Kute
 
Install Wordpress in Ubuntu Linux by Tushar B. Kute
Install Wordpress in Ubuntu Linux by Tushar B. KuteInstall Wordpress in Ubuntu Linux by Tushar B. Kute
Install Wordpress in Ubuntu Linux by Tushar B. Kute
 
Share File easily between computers using sftp
Share File easily between computers using sftpShare File easily between computers using sftp
Share File easily between computers using sftp
 
Signal Handling in Linux
Signal Handling in LinuxSignal Handling in Linux
Signal Handling in Linux
 
Implementation of FIFO in Linux
Implementation of FIFO in LinuxImplementation of FIFO in Linux
Implementation of FIFO in Linux
 
Implementation of Pipe in Linux
Implementation of Pipe in LinuxImplementation of Pipe in Linux
Implementation of Pipe in Linux
 
Basic Multithreading using Posix Threads
Basic Multithreading using Posix ThreadsBasic Multithreading using Posix Threads
Basic Multithreading using Posix Threads
 
Part 04 Creating a System Call in Linux
Part 04 Creating a System Call in LinuxPart 04 Creating a System Call in Linux
Part 04 Creating a System Call in Linux
 
Part 03 File System Implementation in Linux
Part 03 File System Implementation in LinuxPart 03 File System Implementation in Linux
Part 03 File System Implementation in Linux
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module Programming
 
Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)
 
Open source applications softwares
Open source applications softwaresOpen source applications softwares
Open source applications softwares
 
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)Introduction to Ubuntu Edge Operating System (Ubuntu Touch)
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)
 
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B KuteUnit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
 
Technical blog by Engineering Students of Sandip Foundation, itsitrc
Technical blog by Engineering Students of Sandip Foundation, itsitrcTechnical blog by Engineering Students of Sandip Foundation, itsitrc
Technical blog by Engineering Students of Sandip Foundation, itsitrc
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteJava Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
 

Recently uploaded

Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 

Recently uploaded (20)

Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 

Chapter 01 Introduction to Java by Tushar B Kute

  • 1. Java Programming Semester- V Course: CO/CM/IF Tushar B Kute, Assistant Professor, Sandip Institute of Technology and Research Centre, Nashik.
  • 2. Contents ● Java Features and the Java Programming Environment. ● Java Tokens & Data types ● Operators & Expressions ● Decision making & looping
  • 3. Features of Java ● Object Oriented ● Compiled ● Interpreted ● Platform independent ● Portable ● Robust and Secure ● Dynamic.
  • 4. How Java Works[1] Source code Java Compiler bytecode Windows interpreter Linux interpreter MacOs interpreter Solaris interpreter Machine code Machine code Machine code Machine code Windows Computer Linux Computer MacOs Computer Solaris Computer
  • 5. Java Compiler Java program Java compiler Virtual Machine Source code
  • 6. Java Interpreter bytecode Java Interpreter Machine code Virtual Machine Real Machine
  • 7. A Java Program Documentation Section Package Statements Import Statements Interface Statements Class Definitions main method class { main method definition }
  • 8. Java Tokens and Data Types ● Constants & Symbolic Constants, ● Variables ● Dynamic initialization ● Data types ● Array & string ● Scope of variable ● Type casting, ● Standard default values.
  • 9. Java Tokens ● Identifiers ● Keywords ● Literals ● Operators ● Separators
  • 10. Forming a Java Program Alphabets, Digits, Special Symbols Constants, Variables, And Keywords Instructions Program Tokens
  • 11. Constants Constants Numeric Constants Character Constants Floating point Constants Character Constants Integer Constants String Constants Boolean Constants
  • 12. Identifiers Identifiers are the programmer-designed tokens. They are used for naming variables, classes, methods, objects, labels, packages and interfaces in a program. In order to give the name for the identifiers, we have to follow following rules: ● They can have only alphabets, digits, underscore ( _ ) and dollar sign ( $ ) characters. ● They must not begin with digit. Digit can be placed anywhere except staring position. ● Uppercase and lowercase letters are different. ● They can be of any length. ● They must not be the keywords. ● They can have any special symbol in it.
  • 13. Variables A variable is an identifier that denotes a storage location used to store the data value. Unlike constants that may remain unchanged during execution of the program, a variable may take different values at different times during execution of program. A variable name is chosen by the programmer in meaningful way so as to reflect what it represents in the program. Example: total_marks calci average inventory
  • 14. Data types Data Types Primitive Derived Numeric Non -numeric Class Array Interface Integer Real Character Boolean
  • 15. Integer Type Size Minimum Value Maximum Value byte One byte -128 127 short Two bytes -32,768 32,767 int Four bytes -2,147,483,648 2,147,483,647 long Eight bytes -9,223,372,036,854,775,808 9,223,372,036,854,775,807
  • 16. Real Type Size Minimum Value Maximum Value float Four bytes 3.4e–38 3.4e+38 double Eight bytes 1.7e–308 1.7e+308
  • 17. Character In order to store single character constant in a variable, character data type is used. Like C/C++, the keyword char is used to declare character data type variable. Two bytes are required to store a single character in memory. Because, the characters in Java use Unicode system, in which each character is represented by 16 bits i.e. 2 bytes. All characters in Unicode can be stored in a character data type variable.
  • 18. Boolean This is one of the most useful data types of Java. Like bool data type of C++, Boolean data type is used to store two different values. But, values stored inside the boolean type will only be true and false. It can not have values like 0 or 1. It is used in program to test a particular condition during the execution. Boolean is denoted by keyword boolean and uses only one bit of storage. All relational operators (i.e. comparison operators like <, > etc.) return these boolean values.
  • 19. Standard default values Type of variable Default value boolean false byte zero : 0 short zero : 0 int zero : 0 long zero : 0L float 0.0f double 0.0d char null character reference null
  • 20. Scope of variables Basically, the Java variables are categorized into three types: ● Instance variables ● Local variables
  • 21. Scope of the variables According to the types of variables, the scopes of the Java program have following types: ● Block scope ● Class scope
  • 23. Operators and expressions ● Arithmetic Operators, Relational Operators, Logical Operators, Increment & Decrement, Conditional Operators, Bit wise Operators, Instance of Operators, Dot Operators, Operator ● Precedence & associativity ● Evaluation of Expressions ● Type conversions in expressions ● Mathematical Functions – min(), max(), sqrt(), pow(), exp(), round(), abs().
  • 24. Operators ● Arithmetic Operators ● Assignment Operators ● Increment / Decrement Operators ● Relational Operators ● Logical Operators ● Conditional Operators ● Special Operators
  • 25. Arithmetic operators Operator Meaning Example + Addition 9 + 45 – Subtraction 89 – 12 * Multiplication 10 * 3 / Division 18 / 6 % Modulo Division 14 % 3 + Unary Plus +51 – Unary Minus –92
  • 26. Relational operators Operator Meaning < Less than > Greater than <= Less than or equal to >= Greater than or equal to == Equal to != Not equal to
  • 27. Logical operators Operator Meaning && Logical AND || Logical OR ! Logical NOT
  • 28. Increment-Decrement Like C and C++, Java is also having the increment and decrement operators’ i.e. ++ and –– Both of these are unary operators. The operator ++ adds 1 to the operand and – – subtracts 1 from the operand. They are only associated with the variable name, not with the constant or the expression. They can be written in following from: x++ or x—- ++x or --x
  • 29. Conditional The only ternary operator (operator having three operands) is defined in Java called as conditional operator. The character pair ? : is termed as conditional operator. This is used to construct the conditional expression of the following form: condition ? expression2 : expression3
  • 30. Bitwise operators Operator Meaning & Bitwise AND | Bitwise OR ^ Bitwise EX-OR ~ One’s complement << Left shift >> Right shift >>> Right shift with zero fill
  • 31. instanceof instanceof is the keyword called as an object reference binary operator. It returns true if the object on the left-hand side is an instance or object of the class given on the right-hand side. This operator allows us to determine whether the object belong to particular class or not. For example: maharashtra instanceof India
  • 32. Dot operator This is also called as dot operator (.). It is used to access the instance variable and methods of the class using objects. For example: company.salary() //reference to method salary company.employee //reference to variable employee
  • 33. Precedence and Associativity When the expression involves more than one operation, then which operation is to be performed first is decided by the precedence of that operator. Highest precedence operation is solved first. Each operator of Java has precedence associated with it. The operators with the same precedence are evaluated according to there associativity. That is, the expression is evaluated either from left to right or right tot left.
  • 34. Precedenc e Operator Description Associati on 1 . Member selection L to R () Function call L to R [] Array element reference L to R 2 ++,-- Postincrement, Postdecrement R to L 3 ++,-- Preincrement, Predecrement R to L +,- Unary plus, unary minus R to L ~ Bitwise compliment R to L ! Boolean NOT R to L 4 new Create object R to L (type) Type cast R to L 5 *,/,% Multiplication, division, remainder L to R 6 +,- Addition, subtraction L to R + String concatenation L to R
  • 35. 7 <<, >>, >>> Shift operators L to R 8 <, <=, >, >= Less than, less than or equal to, greater than, greater than or equal to L to R instanceof Type comparison L to R 9 ==, != Value equality and inequality L to R ==, != Reference equality and inequality L to R 10 & Boolean AND L to R & Bitwise AND L to R
  • 36. 11 ^ Boolean XOR L to R ^ Bitwise XOR L to R 12 | Boolean OR L to R | Bitwise OR L to R 13 && Conditional AND L to R 14 || Conditional OR L to R 15 ?: Conditional Ternary Operator L to R 16 =,+=,-=, *=,/ =, %=,&=,^=, | =, <<=, >> =, >>>= Assignment Operators R to L
  • 37. Automatic type conversion char byte short int long float double char int int int int long float double byte int int int int long float double short int int int int long float double int int int int int long float double long long long long long long float double float float float float float float float double doubl e double double double double double double double
  • 38. Type promotions rules ● All byte, short and char values are promoted to int. ● If one operand in the expression is long then the whole expression will be promoted to long. ● If one operand is float then the whole expression will be promoted to float. ● If any of the operands is double, the result is double.
  • 39. Type casting In automatic type conversion always lower type is converted to higher type. If we want to convert higher type to lower type then type casting is necessary. For that purpose the type casting operator is used. This type of conversion is called as narrowing the conversion. It takes the following form. (target_type) variable_name;
  • 40. Example: class Casting { public static void main(String args[]) { byte b; int val = 163; b = (byte) val; System.out.println(b); } }
  • 41. Symbolic constants Same way if we want to define the constant in Java one type modifier is used called final. ‘final’ is the keyword used to define the symbolic constant in a Java program. It takes the following form: final data_type variable_name = value; Example: final double Pi = 3.145;
  • 42. Decision making and looping ● if statement ● if-else statement ● switch-case statement ● Conditional operator statement
  • 43. if statement if (condition) statement; or if (condition) { statement1; statement2; statement3; }
  • 44. If statement Entry condition true Statements under ‘if’ statement Statements after ‘if’ statement false
  • 45. Example: 1.if(number < 0) System.out.println(“The number is negative”); 2.if(ch > ‘A’ && ch < ‘Z’) System.out.println(“It is upper case letter”); 3.if(sell_price > cost_price) System.out.println(“You made profit”);
  • 47. Nested-if if(condition1) if(condition2) { statement1; statement2; statement3; }
  • 48. if-else statement if(condition) { statements for condition is true; } else { statements for condition is false; } Statements after the blocks;
  • 51. If-else ladder if(condition1) statement1; else if(condition2) statement2; else if(condition3) statement3; else statement4;
  • 52. Example: if(marks>=75) grade = “distinction”; else if(marks >= 60) grade = “First class”; else if(marks >= 50) grade = “Second class”; else if(marks >= 40) grade = “Pass class”; else grade = “fail”;
  • 53. The switch statement switch(variable) { case value-1: statements-1; break; case value-2: statements-2; break; - - - - - - - - - - - - - - - - - - default: default block; } statement-out;
  • 55. Example: class NumDisplay { public static void main(String args[]) { int x = 6; System.out.println("x = "+x); System.out.print("It is "); switch(x) { case 1: System.out.println("One"); break; case 2: System.out.println("Two"); break; default: System.out.println("No. not correct"); } } }
  • 56. The while loop Initialization; while (condition) { //body of the loop; }
  • 57. Example: int i = 0; while(i<10) { System.out.println(“I Love Java”); I++; }
  • 59. The do-while loop do { //body of the loop; } while(condition);
  • 61. Example: int a = 0; do { System.out.println(“I Love Java”); a++; } while(a<10);
  • 62. The for loop for(initialization ; condition ; increment/decrement) { Body of the loop; }
  • 64. The for loop for(a = 0; a < 10; a++ ) { System.out.println(a); }
  • 65. Comparison while do-while for x = 0; while(x<10) { -------; -------; x++; } x = 0; do { -------; -------; x++; } while(x<10); for(x=0;x<10; x++) { -------; -------; }
  • 66. Nesting of loops for(int x = 0;x<10;x++) { y = 0; while(y<10) { ------; ------; } } -------; -------;
  • 67. The break statement while(condition) { ------; ------; if(condition) break; ------; ------; } ------;
  • 68. Labeled break or labeled loop The general form of the labeled break statement is, break label;
  • 69. Example: class BreakNested { public static void main(String args[]) { outer: for(int x=0;x<10;x++) { System.out.print("This is "+x+": "); for(int y=0;y<10;y++) { if(y==5) break outer; System.out.print(" "+y+" "); } } System.out.println("Program finished..."); } }
  • 70. The continue statement It is useful to force the early iteration of the loop. When we want to continue the next iteration of the loop by skipping some part inside it, the ‘continue’ statement can be used. It is also associated with the condition. General form of the ‘continue’ is: continue;
  • 72. Example: class ContinueDemo { public static void main(String args[]) { for(int i=0; i<10; i++) { if (i%2 == 0) continue; System.out.println(i + " "); } } }
  • 74. Thank you This presentation is created using LibreOffice Impress 4.2.6.3 and available freely under GNU GPL