Declare a variable

Report a typo

Select all invalid lines in the following snippet:

val b1: Byte = 5         // Line 1
val b2: Byte = 2 + 3     // Line 2
val s1: Short = 2 + b1   // Line 3
val s2: Short = 10 + 3L  // Line 4

Tip: The default type for val num = 5 is Int, but you may declare val shortNum: Short = 5 and this declaration is correct. Try to think about what happens if you add 2 and 3! This is just the sum of two numbers, there is no type inference.

Select one or more options from the list
___

Create a free account to access the full topic