Sharing our technical trials in terms of Ubuntu software installs, Blogger hacks, Android and Kotlin learning.
Kotlin-FAQ’s
Kotlin-FAQ’s

Kotlin-FAQ’s

1.
What are bits?

In the world of computers smallest unit for measuring data is called as a bit. A bit can either take value 0 or 1.

2.
What is a Byte?

8 bits make a byte.

3.
How is range for a variable calculated?

2(n-1) is the formula used for calculating range. n is the bits defined for a variable type. And range would be from -2 (n-1) to (2 (n-1)) -1 . For example Int – 32 bits, range for Int would be -2(32-1) to (2(32-1)) -1.

4.
What are binary numbers?

Numbers represented using the digits 0 and 1 are called Binary numbers. Ex: 01101

5.
What are hexadecimal numbers?

Numbers represented using 16 symbols 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F are called as Hexadecimal numbers. Ex: 0x11

6.
What are octal numbers?

Numbers represented using digits 0 to 7 are called as Octal numbers.

7.
Operators in kotlin?

1. Mathematical operators

Symbols used :

( + ) —> Used for addition

( – ) —> Used for subtraction

( * ) —> Used for multiplication

( / ) —> Used for division

( % ) —> Used for modulus

2. Increment decrement operators

Symbols used :

( ++ ) —> Used for incrementing

( – – ) —> Used for decrementing

3. Bitwise operators

Symbols used :

( && ) —> Used for and operation

( || ) —> Used for or operation

( ! ) —> Used for not operation

4. Comparison operators

Symbols used :

( > ) —> Used for greater than

( >= ) —> Used for greater than or equal to

( < ) —> Used for less than

( <= ) —> Used for less than or equal to

5. Assignment operator

Symbols used :

( = ) —> Used for assigning default value

6. Augmented assignment operators

Symbols used :

( += ) —> Used for adding and assigning

( -= ) —> Used for subtracting and assigning

( *= ) —> Used for multiplying and assigning

( /= ) —> Used for dividing and assigning

( %= ) —> Used for finding modulus and assigning

7. Equality operators

Symbols used :

( == ) —> Used for checking equals

( != ) —> Used for checking not equals

8. Referential equality operators

Symbols used :

( === ) —> Used for checking equals

( !== ) —> Used for checking not equals

9. Index access operator

Symbols used :

( [ ] ) —> Used for accessing index

10. Range operator

Symbols used :

( .. ) —> Used for mentioning range

11. Name and type separating operator

Symbols used :

( : ) —> Used for separating the name and type while declaring

12. Null check operators

Symbols used :

( !! ) —> Used for asserting expression is not null

( ?. ) —> Used for specifying, access method or property only if the receiver is non-null

( ?: ) —> ( elvis operator ) Used for deciding which value to take, takes the right-hand value if the left-hand value is null

( ? ) —> Used for marking a type as nullable

13. Some others

Symbols used :

( :: ) —> Used for creating reference to class or member

( -> ) —> Used for separating parameter and body, parameter and return type, condition and body

( @ ) —> Used for annotation

( ; ) —> Used for separating multiple statements used in a same line

( $ ) —> Used for referencing a variable in string template

( _ ) —> Used for substituting unused parameter

( * ) —> Used for passing array as a parameter