SlideShare a Scribd company logo
Core Java

Debasish Pratihari

Type Casting:




Converting one type of data into another must
follow the rules of casting. If a conversion
results in the loss of precision, as in an int
value converted to a short, then the compiler
will issue an error message unless an explicit
cast is made.
a data type with lower precision (fewer bits)
can be converted to a type of higher precision
without explicit casting. To convert a higher
precision type to a lower precision, however,
an explicit cast is required or the compiler will
flag an error.

Primitive Type Conversion Table:

Note :





The symbol C indicates that an explicit
cast is required since the precision is
decreasing.
The symbol A indicates that the precision
is increasing so an automatic cast occurs
without the need for an explicit cast.
N indicates that the conversion is not
allowed.
The * asterisk indicates that the least
significant digits may be lost in the
conversion.

Lecture/core/LF2/05

Page #1

feel the Technology…
Core Java

Debasish Pratihari

&& verses & :


The && operators perform Conditional-AND
operations on two Boolean expressions. These
operators exhibit "short-circuiting" behavior,
which means that the second operand is
evaluated only if needed.



The & operator do the same thing as && but it
does not exhibit "short-circuiting" behavior,
which means that the both operand are
evaluated always.

Enhanced for loop :
Example:1

class LoopDemo{
public static void main(String[] args){
int[] numbers = {1,2,3,4,5,6,7,8,9,10};
for (int item : numbers) {
System.out.println("Count is: " + item);
}
}
}
Example:2

class LoopDemo2{
public static void main(String[] args){
String [] names = {"Debasish","Sushant","Sidharth",
"Sanat","Nayaran"};
for (String name : names) {
System.out.println("Mr. " + name);
}
}
}

Controlling Statement in Java :




The break Statement
o Un-labeled
o Labeled
The continue Statement
o Un-labeled
o Labeled
The return Statement

Lecture/core/LF2/05

Page #2

feel the Technology…
Core Java

Debasish Pratihari

Example of Un-labeled break :
class BreakTest{
public static void main(String args[]){
for( int i=1;i<=5;i++){
System.out.println("Outer loop"+i);
for(int j=10;j<=15;j++){
if(j==12)
break ;
System.out.println("Inner Loop"+j);
}
}
}
}

Example of Labeled break :
class BreakTest{
public static void main(String args[]){
stop:
for( int i=1;i<=5;i++){
System.out.println("Outer loop"+i);
for(int j=10;j<=15;j++){
if(j= =12)
break stop;
System.out.println("Inner Loop"+j);
}
}
}
}

Example of Un-labeled continue :
class ContinueTest{
public static void main(String args[]){
for( int i=1;i<=5;i++){
System.out.println("Outer loop"+i);
for(int j=10;j<=15;j++){
if(j= =12)
continue ;
System.out.println("Inner Loop"+j);
}
}
}
}

Lecture/core/LF2/05

Page #3

feel the Technology…
Core Java

Debasish Pratihari

Example of labeled continue :
class ContinueTest{
public static void main(String args[]){
stop:
for( int i=1;i<=5;i++){
System.out.println("Outer loop"+i);
for(int j=10;j<=15;j++){
if(j==12)
continue stop;
System.out.println("Inner Loop"+j);
}
}
}
}

Variable Scope :
25% 

The Scope of a variable is the part of the program
over which the variable name can be referenced.

class x{
public static void main(String args[]){
int i;
{
int j;
//referring to i and j is ok here
}
//referring to i ok here
//referring to j is not ok here
}
}

Assertion :


An assertion is a statement in the JavaTM
programming language that enables you to test your
assumptions about your program.



Each assertion contains a boolean expression that
you believe will be true when the assertion executes.
If it is not true, the system will throw an error.



The assertion statement has two forms.
o assert Expression1 ;
o assert Expression1 : Expression2 ;
To activate assertions:
o java –ea Test



Lecture/core/LF2/05

Page #4

feel the Technology…

More Related Content

What's hot

8 statement-level control structure
8 statement-level control structure8 statement-level control structure
8 statement-level control structurejigeno
 
Software Engineering - Module 3: Lesson7
Software Engineering - Module 3: Lesson7Software Engineering - Module 3: Lesson7
Software Engineering - Module 3: Lesson7
ArraLafuente
 
Notes: Verilog Part 2 - Modules and Ports - Structural Modeling (Gate-Level M...
Notes: Verilog Part 2 - Modules and Ports - Structural Modeling (Gate-Level M...Notes: Verilog Part 2 - Modules and Ports - Structural Modeling (Gate-Level M...
Notes: Verilog Part 2 - Modules and Ports - Structural Modeling (Gate-Level M...
Jay Baxi
 
Basic Coding In VHDL COding
Basic Coding In VHDL COdingBasic Coding In VHDL COding
Basic Coding In VHDL COding
anna university
 
Operators in java
Operators in javaOperators in java
Operators in java
Then Murugeshwari
 
Std 12 computer java basics part 3 control structure
Std 12 computer java basics part 3 control structureStd 12 computer java basics part 3 control structure
Std 12 computer java basics part 3 control structure
Nuzhat Memon
 
Generic Programming in java
Generic Programming in javaGeneric Programming in java
Generic Programming in java
Garik Kalashyan
 
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDYC UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDYRajeshkumar Reddy
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
talha ijaz
 
Programming in Arduino (Part 2)
Programming in Arduino  (Part 2)Programming in Arduino  (Part 2)
Programming in Arduino (Part 2)
Niket Chandrawanshi
 
Decision making and loop in C#
Decision making and loop in C#Decision making and loop in C#
Decision making and loop in C#
Prasanna Kumar SM
 
Programming in Arduino (Part 1)
Programming in Arduino (Part 1)Programming in Arduino (Part 1)
Programming in Arduino (Part 1)
Niket Chandrawanshi
 
Csharp In Detail Part1
Csharp In Detail Part1Csharp In Detail Part1
Csharp In Detail Part1Mohamed Krar
 
Symbolic Execution (introduction and hands-on)
Symbolic Execution (introduction and hands-on)Symbolic Execution (introduction and hands-on)
Symbolic Execution (introduction and hands-on)
Emilio Coppa
 
12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp
sharvivek
 
Abstract class in java
Abstract class in javaAbstract class in java
Abstract class in java
Lovely Professional University
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Prof .Pragati Khade
 
Interfaces and abstract classes
Interfaces and abstract classesInterfaces and abstract classes
Interfaces and abstract classes
AKANSH SINGHAL
 
Abstract class
Abstract classAbstract class
Abstract class
Hoang Nguyen
 

What's hot (20)

8 statement-level control structure
8 statement-level control structure8 statement-level control structure
8 statement-level control structure
 
Software Engineering - Module 3: Lesson7
Software Engineering - Module 3: Lesson7Software Engineering - Module 3: Lesson7
Software Engineering - Module 3: Lesson7
 
Notes: Verilog Part 2 - Modules and Ports - Structural Modeling (Gate-Level M...
Notes: Verilog Part 2 - Modules and Ports - Structural Modeling (Gate-Level M...Notes: Verilog Part 2 - Modules and Ports - Structural Modeling (Gate-Level M...
Notes: Verilog Part 2 - Modules and Ports - Structural Modeling (Gate-Level M...
 
Basic Coding In VHDL COding
Basic Coding In VHDL COdingBasic Coding In VHDL COding
Basic Coding In VHDL COding
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Std 12 computer java basics part 3 control structure
Std 12 computer java basics part 3 control structureStd 12 computer java basics part 3 control structure
Std 12 computer java basics part 3 control structure
 
Generic Programming in java
Generic Programming in javaGeneric Programming in java
Generic Programming in java
 
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDYC UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
C UNIT-2 PREPARED Y M V BRAHMANANDA REDDY
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Programming in Arduino (Part 2)
Programming in Arduino  (Part 2)Programming in Arduino  (Part 2)
Programming in Arduino (Part 2)
 
Decision making and loop in C#
Decision making and loop in C#Decision making and loop in C#
Decision making and loop in C#
 
Programming in Arduino (Part 1)
Programming in Arduino (Part 1)Programming in Arduino (Part 1)
Programming in Arduino (Part 1)
 
Csharp In Detail Part1
Csharp In Detail Part1Csharp In Detail Part1
Csharp In Detail Part1
 
Symbolic Execution (introduction and hands-on)
Symbolic Execution (introduction and hands-on)Symbolic Execution (introduction and hands-on)
Symbolic Execution (introduction and hands-on)
 
12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp
 
Abstract class in java
Abstract class in javaAbstract class in java
Abstract class in java
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Interfaces and abstract classes
Interfaces and abstract classesInterfaces and abstract classes
Interfaces and abstract classes
 
Abstract class
Abstract classAbstract class
Abstract class
 

Viewers also liked

Right People For The Right Job!
Right People For The Right Job!Right People For The Right Job!
Right People For The Right Job!Geethashree N
 
Bookevent
BookeventBookevent
Bookevent
Sjef Kerkhofs
 
My Mom On Leadership
My Mom On LeadershipMy Mom On Leadership
My Mom On LeadershipMaja Vujovic
 
Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...
Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...
Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...
Paul McElvaney
 
PyCon 2011 Scaling Disqus
PyCon 2011 Scaling DisqusPyCon 2011 Scaling Disqus
PyCon 2011 Scaling Disqus
zeeg
 
Battle of luoisbourg keynote0
Battle of luoisbourg keynote0Battle of luoisbourg keynote0
Battle of luoisbourg keynote0
iamcanehdian
 
Lezing Xerox
Lezing XeroxLezing Xerox
Lezing Xerox
Sjef Kerkhofs
 
Learning Pool CELEB event
Learning Pool CELEB eventLearning Pool CELEB event
Learning Pool CELEB event
Paul McElvaney
 
'E-learning for tackling Dementia' Ed Shrager, Alzheimer’s Society
'E-learning for tackling Dementia' Ed Shrager, Alzheimer’s Society'E-learning for tackling Dementia' Ed Shrager, Alzheimer’s Society
'E-learning for tackling Dementia' Ed Shrager, Alzheimer’s Society
Paul McElvaney
 
Tibo Lezing 27 mei
Tibo Lezing 27 meiTibo Lezing 27 mei
Tibo Lezing 27 mei
Sjef Kerkhofs
 
Aag presentatie 3 februari
Aag presentatie 3 februariAag presentatie 3 februari
Aag presentatie 3 februari
Sjef Kerkhofs
 
If there is no fly v2
If there is no fly v2If there is no fly v2
If there is no fly v2Z3roXIII
 
Dansk Internetbrug 2008 Fdim
Dansk Internetbrug 2008 FdimDansk Internetbrug 2008 Fdim
Dansk Internetbrug 2008 Fdim
One Trick Pony
 
Lcu14 wrap up meeting. Summary of Core Develoment teams achievements
Lcu14 wrap up meeting. Summary of Core Develoment teams achievementsLcu14 wrap up meeting. Summary of Core Develoment teams achievements
Lcu14 wrap up meeting. Summary of Core Develoment teams achievements
Agustin Benito Bethencourt
 
Jane's walk 2012 evolution of ottawa
Jane's walk 2012   evolution of ottawaJane's walk 2012   evolution of ottawa
Jane's walk 2012 evolution of ottawa
Dennis Van Staalduinen
 
Getting your professional message across
Getting your professional message acrossGetting your professional message across
Getting your professional message across
Rhonda Bracey
 
Vov meeting
Vov meeting Vov meeting
Vov meeting
Sjef Kerkhofs
 
Pelajaran 1 Bm
Pelajaran 1 BmPelajaran 1 Bm
Pelajaran 1 Bmamoi286
 
Introduction to chef framework
Introduction to chef frameworkIntroduction to chef framework
Introduction to chef framework
morgoth
 

Viewers also liked (20)

Right People For The Right Job!
Right People For The Right Job!Right People For The Right Job!
Right People For The Right Job!
 
Bookevent
BookeventBookevent
Bookevent
 
My Mom On Leadership
My Mom On LeadershipMy Mom On Leadership
My Mom On Leadership
 
Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...
Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...
Learning Pool's Elaine Walton & Dave Briggs on 'E-learning for Councillors an...
 
PyCon 2011 Scaling Disqus
PyCon 2011 Scaling DisqusPyCon 2011 Scaling Disqus
PyCon 2011 Scaling Disqus
 
Battle of luoisbourg keynote0
Battle of luoisbourg keynote0Battle of luoisbourg keynote0
Battle of luoisbourg keynote0
 
Lezing Xerox
Lezing XeroxLezing Xerox
Lezing Xerox
 
Learning Pool CELEB event
Learning Pool CELEB eventLearning Pool CELEB event
Learning Pool CELEB event
 
'E-learning for tackling Dementia' Ed Shrager, Alzheimer’s Society
'E-learning for tackling Dementia' Ed Shrager, Alzheimer’s Society'E-learning for tackling Dementia' Ed Shrager, Alzheimer’s Society
'E-learning for tackling Dementia' Ed Shrager, Alzheimer’s Society
 
Tibo Lezing 27 mei
Tibo Lezing 27 meiTibo Lezing 27 mei
Tibo Lezing 27 mei
 
Aag presentatie 3 februari
Aag presentatie 3 februariAag presentatie 3 februari
Aag presentatie 3 februari
 
If there is no fly v2
If there is no fly v2If there is no fly v2
If there is no fly v2
 
Dansk Internetbrug 2008 Fdim
Dansk Internetbrug 2008 FdimDansk Internetbrug 2008 Fdim
Dansk Internetbrug 2008 Fdim
 
Lcu14 wrap up meeting. Summary of Core Develoment teams achievements
Lcu14 wrap up meeting. Summary of Core Develoment teams achievementsLcu14 wrap up meeting. Summary of Core Develoment teams achievements
Lcu14 wrap up meeting. Summary of Core Develoment teams achievements
 
Jane's walk 2012 evolution of ottawa
Jane's walk 2012   evolution of ottawaJane's walk 2012   evolution of ottawa
Jane's walk 2012 evolution of ottawa
 
Getting your professional message across
Getting your professional message acrossGetting your professional message across
Getting your professional message across
 
Vov meeting
Vov meeting Vov meeting
Vov meeting
 
Pelajaran 1 Bm
Pelajaran 1 BmPelajaran 1 Bm
Pelajaran 1 Bm
 
Hare And Tortoise
Hare And TortoiseHare And Tortoise
Hare And Tortoise
 
Introduction to chef framework
Introduction to chef frameworkIntroduction to chef framework
Introduction to chef framework
 

Similar to Lecture 5

Basic_Java_02.pptx
Basic_Java_02.pptxBasic_Java_02.pptx
Basic_Java_02.pptx
Kajal Kashyap
 
Ast transformation
Ast transformationAst transformation
Ast transformation
Gagan Agrawal
 
c_tutorial_2.ppt
c_tutorial_2.pptc_tutorial_2.ppt
c_tutorial_2.ppt
gitesh_nagar
 
Introduction to Java Programming Part 2
Introduction to Java Programming Part 2Introduction to Java Programming Part 2
Introduction to Java Programming Part 2
university of education,Lahore
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentalsHCMUTE
 
guia de referencia para a linguagem do fabricante CCS info_syntax.pdf
guia de referencia para a linguagem do fabricante CCS info_syntax.pdfguia de referencia para a linguagem do fabricante CCS info_syntax.pdf
guia de referencia para a linguagem do fabricante CCS info_syntax.pdf
SilvanildoManoeldaSi
 
Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020
Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020
Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020
Andrzej Jóźwiak
 
Pi j1.3 operators
Pi j1.3 operatorsPi j1.3 operators
Pi j1.3 operators
mcollison
 
Unit I Advanced Java Programming Course
Unit I   Advanced Java Programming CourseUnit I   Advanced Java Programming Course
Unit I Advanced Java Programming Course
parveen837153
 
00_Introduction to Java.ppt
00_Introduction to Java.ppt00_Introduction to Java.ppt
00_Introduction to Java.ppt
HongAnhNguyn285885
 
Java Fundamentals
Java FundamentalsJava Fundamentals
Java Fundamentals
Shalabh Chaudhary
 
C++ Interview Question And Answer
C++ Interview Question And AnswerC++ Interview Question And Answer
C++ Interview Question And Answer
Jagan Mohan Bishoyi
 
C++ questions And Answer
C++ questions And AnswerC++ questions And Answer
C++ questions And Answer
lavparmar007
 
Java PSkills-session2.pptx
Java PSkills-session2.pptxJava PSkills-session2.pptx
Java PSkills-session2.pptx
ssuser99ca78
 
C++ unit-1-part-11
C++ unit-1-part-11C++ unit-1-part-11
C++ unit-1-part-11
Jadavsejal
 
C tutorial
C tutorialC tutorial
C tutorial
Anurag Sukhija
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
Julie Iskander
 
Object oriented programming system with C++
Object oriented programming system with C++Object oriented programming system with C++
Object oriented programming system with C++
msharshitha03s
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
K Durga Prasad
 

Similar to Lecture 5 (20)

Basic_Java_02.pptx
Basic_Java_02.pptxBasic_Java_02.pptx
Basic_Java_02.pptx
 
Ast transformation
Ast transformationAst transformation
Ast transformation
 
c_tutorial_2.ppt
c_tutorial_2.pptc_tutorial_2.ppt
c_tutorial_2.ppt
 
Introduction to Java Programming Part 2
Introduction to Java Programming Part 2Introduction to Java Programming Part 2
Introduction to Java Programming Part 2
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
guia de referencia para a linguagem do fabricante CCS info_syntax.pdf
guia de referencia para a linguagem do fabricante CCS info_syntax.pdfguia de referencia para a linguagem do fabricante CCS info_syntax.pdf
guia de referencia para a linguagem do fabricante CCS info_syntax.pdf
 
Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020
Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020
Do I need tests when I have the compiler - Andrzej Jóźwiak - TomTom Dev Day 2020
 
Pi j1.3 operators
Pi j1.3 operatorsPi j1.3 operators
Pi j1.3 operators
 
Unit I Advanced Java Programming Course
Unit I   Advanced Java Programming CourseUnit I   Advanced Java Programming Course
Unit I Advanced Java Programming Course
 
00_Introduction to Java.ppt
00_Introduction to Java.ppt00_Introduction to Java.ppt
00_Introduction to Java.ppt
 
Java Fundamentals
Java FundamentalsJava Fundamentals
Java Fundamentals
 
C++ Interview Question And Answer
C++ Interview Question And AnswerC++ Interview Question And Answer
C++ Interview Question And Answer
 
C++ questions And Answer
C++ questions And AnswerC++ questions And Answer
C++ questions And Answer
 
Java PSkills-session2.pptx
Java PSkills-session2.pptxJava PSkills-session2.pptx
Java PSkills-session2.pptx
 
C++ unit-1-part-11
C++ unit-1-part-11C++ unit-1-part-11
C++ unit-1-part-11
 
C tutorial
C tutorialC tutorial
C tutorial
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
 
Object oriented programming system with C++
Object oriented programming system with C++Object oriented programming system with C++
Object oriented programming system with C++
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 

More from Debasish Pratihari

Lecture 24
Lecture 24Lecture 24
Lecture 24
Debasish Pratihari
 
Lecture 23
Lecture 23Lecture 23
Lecture 23
Debasish Pratihari
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
Debasish Pratihari
 
Lecture 21
Lecture 21Lecture 21
Lecture 21
Debasish Pratihari
 
Lecture 20
Lecture 20Lecture 20
Lecture 20
Debasish Pratihari
 
Lecture 19
Lecture 19Lecture 19
Lecture 19
Debasish Pratihari
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
Debasish Pratihari
 
Lecture 17
Lecture 17Lecture 17
Lecture 17
Debasish Pratihari
 
Lecture 16
Lecture 16Lecture 16
Lecture 16
Debasish Pratihari
 
Lecture 14
Lecture 14Lecture 14
Lecture 14
Debasish Pratihari
 
Lecture 10
Lecture 10Lecture 10
Lecture 10
Debasish Pratihari
 
Lecture 9
Lecture 9Lecture 9
Lecture 8
Lecture 8Lecture 8
Lecture 7
Lecture 7Lecture 7
Lecture 6
Lecture 6Lecture 6
Lecture 4
Lecture 4Lecture 4
Lecture 3
Lecture 3Lecture 3
Lecture 2
Lecture 2Lecture 2
Lecture 1
Lecture 1Lecture 1
Lecture25
Lecture25Lecture25

More from Debasish Pratihari (20)

Lecture 24
Lecture 24Lecture 24
Lecture 24
 
Lecture 23
Lecture 23Lecture 23
Lecture 23
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
 
Lecture 21
Lecture 21Lecture 21
Lecture 21
 
Lecture 20
Lecture 20Lecture 20
Lecture 20
 
Lecture 19
Lecture 19Lecture 19
Lecture 19
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
Lecture 17
Lecture 17Lecture 17
Lecture 17
 
Lecture 16
Lecture 16Lecture 16
Lecture 16
 
Lecture 14
Lecture 14Lecture 14
Lecture 14
 
Lecture 10
Lecture 10Lecture 10
Lecture 10
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Lecture25
Lecture25Lecture25
Lecture25
 

Recently uploaded

Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 

Recently uploaded (20)

Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 

Lecture 5

  • 1. Core Java Debasish Pratihari Type Casting:   Converting one type of data into another must follow the rules of casting. If a conversion results in the loss of precision, as in an int value converted to a short, then the compiler will issue an error message unless an explicit cast is made. a data type with lower precision (fewer bits) can be converted to a type of higher precision without explicit casting. To convert a higher precision type to a lower precision, however, an explicit cast is required or the compiler will flag an error. Primitive Type Conversion Table: Note :     The symbol C indicates that an explicit cast is required since the precision is decreasing. The symbol A indicates that the precision is increasing so an automatic cast occurs without the need for an explicit cast. N indicates that the conversion is not allowed. The * asterisk indicates that the least significant digits may be lost in the conversion. Lecture/core/LF2/05 Page #1 feel the Technology…
  • 2. Core Java Debasish Pratihari && verses & :  The && operators perform Conditional-AND operations on two Boolean expressions. These operators exhibit "short-circuiting" behavior, which means that the second operand is evaluated only if needed.  The & operator do the same thing as && but it does not exhibit "short-circuiting" behavior, which means that the both operand are evaluated always. Enhanced for loop : Example:1 class LoopDemo{ public static void main(String[] args){ int[] numbers = {1,2,3,4,5,6,7,8,9,10}; for (int item : numbers) { System.out.println("Count is: " + item); } } } Example:2 class LoopDemo2{ public static void main(String[] args){ String [] names = {"Debasish","Sushant","Sidharth", "Sanat","Nayaran"}; for (String name : names) { System.out.println("Mr. " + name); } } } Controlling Statement in Java :    The break Statement o Un-labeled o Labeled The continue Statement o Un-labeled o Labeled The return Statement Lecture/core/LF2/05 Page #2 feel the Technology…
  • 3. Core Java Debasish Pratihari Example of Un-labeled break : class BreakTest{ public static void main(String args[]){ for( int i=1;i<=5;i++){ System.out.println("Outer loop"+i); for(int j=10;j<=15;j++){ if(j==12) break ; System.out.println("Inner Loop"+j); } } } } Example of Labeled break : class BreakTest{ public static void main(String args[]){ stop: for( int i=1;i<=5;i++){ System.out.println("Outer loop"+i); for(int j=10;j<=15;j++){ if(j= =12) break stop; System.out.println("Inner Loop"+j); } } } } Example of Un-labeled continue : class ContinueTest{ public static void main(String args[]){ for( int i=1;i<=5;i++){ System.out.println("Outer loop"+i); for(int j=10;j<=15;j++){ if(j= =12) continue ; System.out.println("Inner Loop"+j); } } } } Lecture/core/LF2/05 Page #3 feel the Technology…
  • 4. Core Java Debasish Pratihari Example of labeled continue : class ContinueTest{ public static void main(String args[]){ stop: for( int i=1;i<=5;i++){ System.out.println("Outer loop"+i); for(int j=10;j<=15;j++){ if(j==12) continue stop; System.out.println("Inner Loop"+j); } } } } Variable Scope : 25%  The Scope of a variable is the part of the program over which the variable name can be referenced. class x{ public static void main(String args[]){ int i; { int j; //referring to i and j is ok here } //referring to i ok here //referring to j is not ok here } } Assertion :  An assertion is a statement in the JavaTM programming language that enables you to test your assumptions about your program.  Each assertion contains a boolean expression that you believe will be true when the assertion executes. If it is not true, the system will throw an error.  The assertion statement has two forms. o assert Expression1 ; o assert Expression1 : Expression2 ; To activate assertions: o java –ea Test  Lecture/core/LF2/05 Page #4 feel the Technology…