SlideShare a Scribd company logo
1 of 72
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-kotlinZoran 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 top features overview
Kotlin top features overviewKotlin top features overview
Kotlin top features overviewDennis 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 Developertroubledkumi
 
Kotlin - A Programming Language
Kotlin - A Programming Language Kotlin - A Programming Language
Kotlin - A Programming Language Mobio Solutions
 
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 developmentJayaprakash R
 
Something for Nothing
Something for NothingSomething for Nothing
Something for NothingKevlin Henney
 
Modern Programming Languages - An overview
Modern Programming Languages - An overviewModern Programming Languages - An overview
Modern Programming Languages - An overviewAyman 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 Patterntcab22
 
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 languageAntonis Lilis
 
Getting started with scala cats
Getting started with scala catsGetting started with scala cats
Getting started with scala catsKnoldus Inc.
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developersMohamed Wael
 
Kotlin presentation
Kotlin presentation Kotlin presentation
Kotlin presentation MobileAcademy
 
Kotlin generics
Kotlin genericsKotlin generics
Kotlin genericsLinusMuema
 
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.pdfTechugo
 

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

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.pptxShayantaniKar
 
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.pptxShayantaniKar
 
Day1 Compose Camp.pptx
Day1 Compose Camp.pptxDay1 Compose Camp.pptx
Day1 Compose Camp.pptxShayantaniKar
 

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

History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 

Recently uploaded (20)

History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 

Day 2 Compose Camp.pptx