TheBulgarianWolf

Abstract Class Kotlin

Apr 4th, 2021
547
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. abstract class PersonAb(name:String){
  2.     init{
  3.         println("My name is $name")
  4.     }
  5.  
  6.     fun displaySSN(ssn: Int){
  7.         println("My SSN is $ssn")
  8.     }
  9.  
  10.     abstract fun displayJob(description: String)
  11. }
  12.  
  13. class Teacher(name: String) : PersonAb(name){
  14.     override fun displayJob(description: String) {
  15.         println(description)
  16.     }
  17. }
  18.  
  19. fun main(args: Array<String>){
  20.     val jack = Teacher("Jack Smith")
  21.     jack.displayJob("I am a physics teacher.")
  22.     jack.displaySSN(23123)
  23. }
RAW Paste Data