SlideShare a Scribd company logo
Welcome to
Day 2
Similar logic like other programming languages.
SYNTAX for basic if/else condition:
You learned how to use if/else and when as statements.
You can also use conditionals as expressions to return
different values for each branch of condition.
You learned how to use if/else and when as statements.
You can also use conditionals as expressions to return
different values for each branch of condition.
Kotlin null safety is a procedure to eliminate the risk of null reference from the code. Kotlin
compiler throws Null Pointer Exception immediately if it is found any null argument is passed
without executing any other statements.
In Java this would be the equivalent of a Null Pointer Exception, or an NPE for short.
Q01
Nullable types (can hold null) and
non-nullable types(can’t hold null)
Declare Nullable type:
Q01
Q01
Nullable types (can hold null) and
non-nullable types(can’t hold null)
Declare Nullable type:
Q01
Nullable types (can hold null) and
non-nullable types(can’t hold null)
Declare Nullable type:
Q02
The code fails at compile time because the direct reference to the length property for the favoriteActor
variable isn't allowed because there's a possibility that the variable is null.
This causes a critical issue - known as null reference - attempt to access a member of a variable that is null.
This might cause the app to crash. This type of crash is known as runtime error.
Due to the null safety nature of Kotlin, such runtime errors are prevented because the Kotlin compiler
forces a null check for nullable types. Null check refers to a process of checking whether a variable could be
null before it's accessed and treated as a non-nullable type. If you wish to use a nullable value as its non-
nullable type, you need to perform a null check explicitly.
The safe-call operator allows safer access to nullable variables because the Kotlin compiler stops any
attempt of member access to null references and returns null for the member accessed
The safe-call operator allows safer access to nullable variables because the Kotlin compiler stops any
attempt of member access to null references and returns null for the member accessed
It means that you assert that the value of the variable isn't null, regardless of whether it is or isn't.
It means that you assert that the value of the variable isn't null, regardless of whether it is or isn't.
You get Null Pointer Exception
Understanding the test:
If the variable isn't null, the expression before the ?: Elvis operator executes. If the variable is null, the
expression after the ?:
How can we express the previous problem using Elvis operator ?
If the variable isn't null, the expression before the ?: Elvis operator executes. If the variable is null, the
expression after the ?:
How can we express the previous problem using Elvis operator ?
OOPS in
Kotlin
OOPS in Kotlin
OOPs is generally the abbreviation of the name Object Oriented Programming. In simple language
suppose we want to build a car then first we have to make a design called CLASS and the real car
called OBJECT.
CLASS
OOPS in Kotlin
OOPs is generally the abbreviation of the name Object Oriented Programming. In simple language
suppose we want to build a car then first we have to make a design called CLASS and the real car
called OBJECT.
CLASS OBJECT
OOPS in Kotlin
OOPS in Kotlin
Encapsulation
Wraps the related properties and methods that perform action on
those properties in a class.
OOPS in Kotlin
Abstraction
The idea is to hide the internal implementation logic as much as
possible.
OOPS in Kotlin
Inheritance
Enables you to build a class upon the characteristics and behavior
of other classes by establishing a parent-child relationship.
OOPS in Kotlin
Polymorphism
Ability to use different objects in a single, common way.
OOPS in Kotlin
•
•
•
OOPS in Kotlin
OOPS in Kotlin
OOPS in Kotlin
OOPS in Kotlin
Q03
OOPS in Kotlin
OOPS in Kotlin
OOPS in Kotlin
OOPS in Kotlin
OOPS in Kotlin
OOPS in Kotlin
OOPS in Kotlin
v
OOPS in Kotlin
OOPS in Kotlin
OOPS in Kotlin
OOPS in Kotlin
OOPS in Kotlin
OOPS in Kotlin
IS-A Relationship
HAS-A Relationship
OOPS in Kotlin
OOPS in Kotlin
•
•
•
•
OOPS in Kotlin
OOPS in Kotlin
OOPS in Kotlin
OOPS in Kotlin
OOPS in Kotlin
OOPS in Kotlin
•
•
•
•
Day 2 Compose Camp.pptx
Day 2 Compose Camp.pptx

More Related Content

Similar to Day 2 Compose Camp.pptx

9054799 dzone-refcard267-kotlin
9054799 dzone-refcard267-kotlin9054799 dzone-refcard267-kotlin
9054799 dzone-refcard267-kotlin
Zoran Stanimirovic
 
How to replace switch with when in kotlin
How to replace switch with when in kotlin How to replace switch with when in kotlin
How to replace switch with when in kotlin
Concetto Labs
 
Kotlin
KotlinKotlin
Kotlin top features overview
Kotlin top features overviewKotlin top features overview
Kotlin top features overview
Dennis Boanini
 
What's new with Kotlin - Google IO18' extended Covenant University.
What's new with Kotlin - Google IO18' extended Covenant University.What's new with Kotlin - Google IO18' extended Covenant University.
What's new with Kotlin - Google IO18' extended Covenant University.
SimileoluwaAluko
 
Introduction to kotlin for Java Developer
Introduction to kotlin for Java DeveloperIntroduction to kotlin for Java Developer
Introduction to kotlin for Java Developer
troubledkumi
 
Kotlin - A Programming Language
Kotlin - A Programming Language Kotlin - A Programming Language
Kotlin - A Programming Language
Mobio Solutions
 
Introduction to Kotlin - Android KTX
Introduction to Kotlin - Android KTXIntroduction to Kotlin - Android KTX
Introduction to Kotlin - Android KTX
Syed Awais Mazhar Bukhari
 
Exploring Kotlin language basics for Android App development
Exploring Kotlin language basics for Android App developmentExploring Kotlin language basics for Android App development
Exploring Kotlin language basics for Android App development
Jayaprakash R
 
Something for Nothing
Something for NothingSomething for Nothing
Something for Nothing
Kevlin Henney
 
Modern Programming Languages - An overview
Modern Programming Languages - An overviewModern Programming Languages - An overview
Modern Programming Languages - An overview
Ayman Mahfouz
 
Introduction to Koltin for Android Part I
Introduction to Koltin for Android Part I Introduction to Koltin for Android Part I
Introduction to Koltin for Android Part I
Atif AbbAsi
 
Null Object Design Pattern
Null Object Design PatternNull Object Design Pattern
Null Object Design Pattern
tcab22
 
Is this Swift for Android? A short introduction to the Kotlin language
Is this Swift for Android? A short introduction to the Kotlin languageIs this Swift for Android? A short introduction to the Kotlin language
Is this Swift for Android? A short introduction to the Kotlin language
Antonis Lilis
 
Getting started with scala cats
Getting started with scala catsGetting started with scala cats
Getting started with scala cats
Knoldus Inc.
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developers
Mohamed Wael
 
Kotlin presentation
Kotlin presentation Kotlin presentation
Kotlin presentation
MobileAcademy
 
Kotlin generics
Kotlin genericsKotlin generics
Kotlin generics
LinusMuema
 
Kotlin vs Java-A Comparison for Application Development Projects.pdf
Kotlin vs Java-A Comparison for Application Development Projects.pdfKotlin vs Java-A Comparison for Application Development Projects.pdf
Kotlin vs Java-A Comparison for Application Development Projects.pdf
Techugo
 

Similar to Day 2 Compose Camp.pptx (20)

9054799 dzone-refcard267-kotlin
9054799 dzone-refcard267-kotlin9054799 dzone-refcard267-kotlin
9054799 dzone-refcard267-kotlin
 
How to replace switch with when in kotlin
How to replace switch with when in kotlin How to replace switch with when in kotlin
How to replace switch with when in kotlin
 
Kotlin
KotlinKotlin
Kotlin
 
Kotlin top features overview
Kotlin top features overviewKotlin top features overview
Kotlin top features overview
 
What's new with Kotlin - Google IO18' extended Covenant University.
What's new with Kotlin - Google IO18' extended Covenant University.What's new with Kotlin - Google IO18' extended Covenant University.
What's new with Kotlin - Google IO18' extended Covenant University.
 
Introduction to kotlin for Java Developer
Introduction to kotlin for Java DeveloperIntroduction to kotlin for Java Developer
Introduction to kotlin for Java Developer
 
Kotlin - A Programming Language
Kotlin - A Programming Language Kotlin - A Programming Language
Kotlin - A Programming Language
 
Introduction to Kotlin - Android KTX
Introduction to Kotlin - Android KTXIntroduction to Kotlin - Android KTX
Introduction to Kotlin - Android KTX
 
Exploring Kotlin language basics for Android App development
Exploring Kotlin language basics for Android App developmentExploring Kotlin language basics for Android App development
Exploring Kotlin language basics for Android App development
 
Something for Nothing
Something for NothingSomething for Nothing
Something for Nothing
 
Modern Programming Languages - An overview
Modern Programming Languages - An overviewModern Programming Languages - An overview
Modern Programming Languages - An overview
 
Introduction to Koltin for Android Part I
Introduction to Koltin for Android Part I Introduction to Koltin for Android Part I
Introduction to Koltin for Android Part I
 
Null Object Design Pattern
Null Object Design PatternNull Object Design Pattern
Null Object Design Pattern
 
Is this Swift for Android? A short introduction to the Kotlin language
Is this Swift for Android? A short introduction to the Kotlin languageIs this Swift for Android? A short introduction to the Kotlin language
Is this Swift for Android? A short introduction to the Kotlin language
 
Getting started with scala cats
Getting started with scala catsGetting started with scala cats
Getting started with scala cats
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developers
 
Kotlin presentation
Kotlin presentation Kotlin presentation
Kotlin presentation
 
Kotlin generics
Kotlin genericsKotlin generics
Kotlin generics
 
OCL in EMF
OCL in EMFOCL in EMF
OCL in EMF
 
Kotlin vs Java-A Comparison for Application Development Projects.pdf
Kotlin vs Java-A Comparison for Application Development Projects.pdfKotlin vs Java-A Comparison for Application Development Projects.pdf
Kotlin vs Java-A Comparison for Application Development Projects.pdf
 

More from ShayantaniKar

GCCP Day 1.pptx
GCCP Day 1.pptxGCCP Day 1.pptx
GCCP Day 1.pptx
ShayantaniKar
 
Hacktoberfest.pptx
Hacktoberfest.pptxHacktoberfest.pptx
Hacktoberfest.pptx
ShayantaniKar
 
Day 3 Compose Camp Material Design.pptx
Day 3 Compose Camp Material Design.pptxDay 3 Compose Camp Material Design.pptx
Day 3 Compose Camp Material Design.pptx
ShayantaniKar
 
Day 3 Compose Camp Kotlin Fundamentals.pptx
Day 3 Compose Camp Kotlin Fundamentals.pptxDay 3 Compose Camp Kotlin Fundamentals.pptx
Day 3 Compose Camp Kotlin Fundamentals.pptx
ShayantaniKar
 
Day1 Compose Camp.pptx
Day1 Compose Camp.pptxDay1 Compose Camp.pptx
Day1 Compose Camp.pptx
ShayantaniKar
 
InfoSession.pptx
InfoSession.pptxInfoSession.pptx
InfoSession.pptx
ShayantaniKar
 

More from ShayantaniKar (6)

GCCP Day 1.pptx
GCCP Day 1.pptxGCCP Day 1.pptx
GCCP Day 1.pptx
 
Hacktoberfest.pptx
Hacktoberfest.pptxHacktoberfest.pptx
Hacktoberfest.pptx
 
Day 3 Compose Camp Material Design.pptx
Day 3 Compose Camp Material Design.pptxDay 3 Compose Camp Material Design.pptx
Day 3 Compose Camp Material Design.pptx
 
Day 3 Compose Camp Kotlin Fundamentals.pptx
Day 3 Compose Camp Kotlin Fundamentals.pptxDay 3 Compose Camp Kotlin Fundamentals.pptx
Day 3 Compose Camp Kotlin Fundamentals.pptx
 
Day1 Compose Camp.pptx
Day1 Compose Camp.pptxDay1 Compose Camp.pptx
Day1 Compose Camp.pptx
 
InfoSession.pptx
InfoSession.pptxInfoSession.pptx
InfoSession.pptx
 

Recently uploaded

Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 

Recently uploaded (20)

Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 

Day 2 Compose Camp.pptx