Upgrade to Pro — share decks privately, control downloads, hide ads and more …

8 Kotlin Pop Quizzes

8 Kotlin Pop Quizzes

Hiroshi Kurokawa

August 22, 2017
Tweet

More Decks by Hiroshi Kurokawa

Other Decks in Technology

Transcript

  1. 4FD 3 Quiz 1. fun sum(a: Int, b: Int) =

    { a + b } println(sum(1, 1))     
  2. 4 Quiz 1. fun sum(a: Int, b: Int) = {

    a + b } println(sum(1, 1)) 'VODUJPOKBWBMBOH*OUFHFS IUUQTLPUMJOMBOHPSHEPDTSFGFSFODF GVODUJPOTIUNMTJOHMFFYQSFTTJPOGVODUJPOT
  3. 5 Quiz 1. fun sum(a: Int, b: Int) = a

    + b println(sum(1, 1)) 'VODUJPOKBWBMBOH*OUFHFS IUUQTLPUMJOMBOHPSHEPDTSFGFSFODF GVODUJPOTIUNMTJOHMFFYQSFTTJPOGVODUJPOT
  4. 6 Quiz 1. fun sum(a: Int, b: Int) = a

    + b println(sum(1, 1))  IUUQTLPUMJOMBOHPSHEPDTSFGFSFODF GVODUJPOTIUNMTJOHMFFYQSFTTJPOGVODUJPOT
  5. 7 Quiz 2. (1..5).forEach({ i -> if (i > 3)

    return println(i) }) println("Done") 4FD     
  6. 8 Quiz 2. (1..5).forEach({ i -> if (i > 3)

    return println(i) }) println("Done")    IUUQTLPUMJOMBOHPSHEPDTSFGFSFODFJOMJOF GVODUJPOTIUNMOPOMPDBMSFUVSOT
  7. val ___ = 010 println(val) 10 Quiz 3. &SSPS6OFYQFDUFEUPLFOT VTFUPTFQBSBUFFYQSFTTJPOTPOUIFTBNFMJOF

     &SSPS6OTVQQPSUFE<MJUFSBMQSFYFTBOETVYFT> &SSPS/BNFT@ @@ @@@  BSFSFTFSWFEJO,PUMJO @ @@ @@@ ʜBSFSFTFSWFEWBSJBCMFOBNFT %FDJNBMMJUFSBMDBOOPUTUBSUXJUIb` IUUQKFUCSBJOTHJUIVCJPLPUMJOTQFD@JEFOUJpFST IUUQKFUCSBJOTHJUIVCJPLPUMJOTQFD@EFDJNBM@MJUFSBMT
  8. 11 Quiz 4. open class A(val x: Any?) object B

    : A(C) object C : A(B) println(B.x) println(C.x) 4FD     
  9. 12 Quiz 4. open class A(val x: Any?) object B

    : A(C) object C : A(B) println(B.x) println(C.x) $!GFG OVMM IUUQKFUCSBJOTHJUIVCJPLPUMJOTQFD@TJOHMFUPO@PCKFDUT
  10. 15 Quiz 6. class A { init { f() .}

    val a = "a" fun f() { println(a) } } A() 4FD     
  11. OVMM 16 Quiz 6. class A { init { f()

    䠼} val a = "a" fun f() { println(a) 䠼} 䠼} A() IUUQRJJUBDPNPNPDIJNFUBSVJUFNTCBBCGGF
  12. OVMM 17 Quiz 6. class A { val a =

    "a" init { f() 䠼} fun f() { println(a) 䠼} 䠼} A() IUUQRJJUBDPNPNPDIJNFUBSVJUFNTCBBCGGF
  13. B 18 Quiz 6. class A { val a =

    "a" init { f() 䠼} fun f() { println(a) 䠼} 䠼} A() IUUQRJJUBDPNPNPDIJNFUBSVJUFNTCBBCGGF
  14. 19 Quiz 7. println(127 as Int? === 127 as Int?)

    println(128 as Int? === 128 as Int?) 4FD     
  15. 20 Quiz 7. println(127 as Int? === 127 as Int?)

    println(128 as Int? === 128 as Int?) USVF GBMTF IUUQTTUBDLPWFSqPXDPNB
  16. 22 Quiz 8. println(2.5 in 1..3) println(3.5 in 1..3) USVF

    USVF IUUQTZPVUSBDLKFUCSBJOTDPNJTTVF,5