SlideShare a Scribd company logo
1 of 18
Download to read offline
Compose Camp
Android Basics with Compose:
Unit 2
Today's Speakers
Bhavik Kothari
Gopal Meena
Co-Facilitator
Facilitator
● What is kotlin
● Datatypes in kotlin
● How to use Functions in kotlin
What we have discussed
What is OOPs
Object Oreinted Programming is
a programming paradigm based
on the concept of "objects" which
can contain data and code
Encapsulation
Abstraction
Inheritance
Polimorphism
Encapsulation
Encapsulation is union data
and logic to one unit and hide
data from external access.
class Animal {
var name: String
var noOfLegs: Int
....
}
Modifiers
Public
Private
Protected
internal
class Animal {
private:
var name: String
public :
var noOfLegs: Int
protected :
var height: Int
}
Creating a class
The objects are created from the
Kotlin class and they share the
common properties and behaviour
defined by a class in form of data
members and member functions
respectively.
class myClass {
private var name: String = "Hello"
fun printMe() {
print("Hello: " + name)
}
}
fun main() {
val obj = myClass()
obj.printMe()
}
abstract class Bank {
abstract fun percentage(p: Int)
...
}
class SBI : Bank() {
override fun percentage(p: Int){
println(p/100)
}
}
What is inheritance
Inheritance enables code re-
usability, it allows all the features
from a base class to be inherited
by a derived class. In addition,
the derived class can also add
some features of its own.
Inheritance
Base Class
Variables
Public Mode
Derived Derived
Derived
Protected Mode
Private Mode
Public
Private
Protected
Public Private Protected
Not Inherited Not Inherited Not Inherited
Protected Protected
Private
Defining an
Abstract Class
A class which can not be
instantiated. This means we
cannot create objects of an
abstract class.
abstract class Bank {
abstract fun percentage(p: Int)
...
}
class SBI : Bank() {
override fun percentage(p: Int){
println(p/100)
}
}
What is override and super
Override:
Method overriding means to
redefine or modify the method of
the base class in its derived class.
Super:
The super keyword will call the
constructor of the super or parent
class to initialize the properties of
the parent class
class SBI : Bank() {
override fun percentage(p: Int){
println(p/100)
}
}
What is Interface
Interfaces are custom types provided
by Kotlin that cannot be instantiated
directly. Instead, these define a form
of behavior that the implementing
types have to follow
interface Vehicle{
fun start()
fun stop()
}
class Car : Vehicle {
override fun start() {
print("Vehicle started")
}
override fun stop() {
print("Vehicle stopped")
}
}
Need of interface?
We can implement multiple interfaces but can't do the same with
abstract class.
Have to specify abstract keyword with a function in abstract class
but in interface its by default.
Interface enables users to learn the system quickly and use it
efficiently.
Putting it together with abstract class
abstract class Bank {
abstract fun percentage(p: Int)
}
class SBI : Bank() {
override fun percentage(p: Int){
println(p/100)
}
}
fun main(){
val sbi = SBI()
sbi.percentage(200)
}
Output: 2
Putting it together with interface
interface Bank {
fun percentage(p: Int)
{ println("Super Func Call") }
}
class SBI : Bank {
override fun percentage(p: Int){
super.percentage(p)
println(p/100)
}
}
fun main(){
val sbi = SBI()
sbi.percentage(200)
}
Output: Super Func Call
2
Get Ready For Quiz
Work on Unit 2
Have a Question? Just ask
What’s coming next:
Back to back live coding session in which you are going to build an exciting
application:
Budget Tracker
Application

More Related Content

Similar to Compose Camp - Intro.pdf

Md02 - Getting Started part-2
Md02 - Getting Started part-2Md02 - Getting Started part-2
Md02 - Getting Started part-2Rakesh Madugula
 
Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#Abid Kohistani
 
Jedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented conceptsJedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented conceptsMaryo Manjaruni
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++Amresh Raj
 
Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)Abu Saleh
 
Classes & objects new
Classes & objects newClasses & objects new
Classes & objects newlykado0dles
 
ITTutor Advanced Java (1).pptx
ITTutor Advanced Java (1).pptxITTutor Advanced Java (1).pptx
ITTutor Advanced Java (1).pptxkristinatemen
 
C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1ReKruiTIn.com
 
oops with java modules i & ii.ppt
oops with java modules i & ii.pptoops with java modules i & ii.ppt
oops with java modules i & ii.pptrani marri
 

Similar to Compose Camp - Intro.pdf (20)

Md02 - Getting Started part-2
Md02 - Getting Started part-2Md02 - Getting Started part-2
Md02 - Getting Started part-2
 
SEMINAR
SEMINARSEMINAR
SEMINAR
 
Seminar
SeminarSeminar
Seminar
 
My c++
My c++My c++
My c++
 
Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#Polymorphism in C# Function overloading in C#
Polymorphism in C# Function overloading in C#
 
C++ Interview Questions
C++ Interview QuestionsC++ Interview Questions
C++ Interview Questions
 
Jedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented conceptsJedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented concepts
 
Lecture6.ppt
Lecture6.pptLecture6.ppt
Lecture6.ppt
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++
 
Php oop (1)
Php oop (1)Php oop (1)
Php oop (1)
 
Advance oops concepts
Advance oops conceptsAdvance oops concepts
Advance oops concepts
 
Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)Lecture 4.2 c++(comlete reference book)
Lecture 4.2 c++(comlete reference book)
 
Java For Automation
Java   For AutomationJava   For Automation
Java For Automation
 
Classes & objects new
Classes & objects newClasses & objects new
Classes & objects new
 
Design patterns
Design patternsDesign patterns
Design patterns
 
OOC MODULE1.pptx
OOC MODULE1.pptxOOC MODULE1.pptx
OOC MODULE1.pptx
 
ITTutor Advanced Java (1).pptx
ITTutor Advanced Java (1).pptxITTutor Advanced Java (1).pptx
ITTutor Advanced Java (1).pptx
 
C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1
 
SRAVANByCPP
SRAVANByCPPSRAVANByCPP
SRAVANByCPP
 
oops with java modules i & ii.ppt
oops with java modules i & ii.pptoops with java modules i & ii.ppt
oops with java modules i & ii.ppt
 

Recently uploaded

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
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
 
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
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
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
 
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
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
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
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

Compose Camp - Intro.pdf

  • 1. Compose Camp Android Basics with Compose: Unit 2
  • 2. Today's Speakers Bhavik Kothari Gopal Meena Co-Facilitator Facilitator
  • 3. ● What is kotlin ● Datatypes in kotlin ● How to use Functions in kotlin What we have discussed
  • 4. What is OOPs Object Oreinted Programming is a programming paradigm based on the concept of "objects" which can contain data and code Encapsulation Abstraction Inheritance Polimorphism
  • 5. Encapsulation Encapsulation is union data and logic to one unit and hide data from external access. class Animal { var name: String var noOfLegs: Int .... }
  • 6. Modifiers Public Private Protected internal class Animal { private: var name: String public : var noOfLegs: Int protected : var height: Int }
  • 7. Creating a class The objects are created from the Kotlin class and they share the common properties and behaviour defined by a class in form of data members and member functions respectively. class myClass { private var name: String = "Hello" fun printMe() { print("Hello: " + name) } } fun main() { val obj = myClass() obj.printMe() }
  • 8. abstract class Bank { abstract fun percentage(p: Int) ... } class SBI : Bank() { override fun percentage(p: Int){ println(p/100) } } What is inheritance Inheritance enables code re- usability, it allows all the features from a base class to be inherited by a derived class. In addition, the derived class can also add some features of its own.
  • 9. Inheritance Base Class Variables Public Mode Derived Derived Derived Protected Mode Private Mode Public Private Protected Public Private Protected Not Inherited Not Inherited Not Inherited Protected Protected Private
  • 10. Defining an Abstract Class A class which can not be instantiated. This means we cannot create objects of an abstract class. abstract class Bank { abstract fun percentage(p: Int) ... } class SBI : Bank() { override fun percentage(p: Int){ println(p/100) } }
  • 11. What is override and super Override: Method overriding means to redefine or modify the method of the base class in its derived class. Super: The super keyword will call the constructor of the super or parent class to initialize the properties of the parent class class SBI : Bank() { override fun percentage(p: Int){ println(p/100) } }
  • 12. What is Interface Interfaces are custom types provided by Kotlin that cannot be instantiated directly. Instead, these define a form of behavior that the implementing types have to follow interface Vehicle{ fun start() fun stop() } class Car : Vehicle { override fun start() { print("Vehicle started") } override fun stop() { print("Vehicle stopped") } }
  • 13. Need of interface? We can implement multiple interfaces but can't do the same with abstract class. Have to specify abstract keyword with a function in abstract class but in interface its by default. Interface enables users to learn the system quickly and use it efficiently.
  • 14. Putting it together with abstract class abstract class Bank { abstract fun percentage(p: Int) } class SBI : Bank() { override fun percentage(p: Int){ println(p/100) } } fun main(){ val sbi = SBI() sbi.percentage(200) } Output: 2
  • 15. Putting it together with interface interface Bank { fun percentage(p: Int) { println("Super Func Call") } } class SBI : Bank { override fun percentage(p: Int){ super.percentage(p) println(p/100) } } fun main(){ val sbi = SBI() sbi.percentage(200) } Output: Super Func Call 2
  • 17. Work on Unit 2 Have a Question? Just ask
  • 18. What’s coming next: Back to back live coding session in which you are going to build an exciting application: Budget Tracker Application