Type checking

Report a typo

Select all invalid lines in the following snippet.

val b0: Byte = 2
val s0: Short = 10
val n0: Int = 5    
val l0: Long = 14
val f0: Float = 11.4f

val b: Byte = 5                 
val s: Short = 2 + b0           
val n: Int = s0.toByte() + 2    
val l: Long = n0 + 4            
val f: Float = l0.toFloat() + 1 
val d: Double = f0 / 1          

Keep in mind that you cannot assign a value of type Float to a variable of type Double and so on. And remember the rules:

  1. If either operand is of type Double, the result is Double.
  2. Otherwise, if either operand is of type Float, the result is Float.
  3. Otherwise, if either operand is of type Long, the result is Long.
  4. Otherwise, the result is Int.
Select one or more options from the list
___

Create a free account to access the full topic