Encapsulation in kotlin

 package com.example.my_kotlin_practice


fun main(args: Array<String>)
{
val instance_a:A2 = A2()
instance_a.
a
}
var a = 0
private fun abc() {
println("This is 'abc' function")
}
open class A2 {
var a = 10
private var b = 12
protected fun xyz() {}
}
internal class B2: A2() {
fun abc() {
super.xyz()
}
}
Above file is Encapsulation.kt file
Below file is Encapsulation2.kt file

package com.example.my_kotlin_practice

fun main(args: Array<String>)
{
val b2 = B2()
}

OUTPUT :

Process finished with exit code 0

Comments

Popular posts from this blog

Maps (Collections) in kotlin

Functions in Kotlin

Arrays in Kotlin