Identifiers in a programming language are the names given to a class, method, variable or object to identify them in the program.
e.g.:- myObject, main, args, value1, etc.
Identifiers in a programming language are the names given to a class, method, variable or object to identify them in the program.
e.g.:- myObject, main, args, value1, etc.
A variable is named a reference to a memory location. The location stores the data that is used by the program.
a)
Mutable Collections
b) Immutable Collections
a)
Mutable Variables are those that allow us to change its value any time in
the code.
e.g.: var keyword
b)
Immutable Variables that are
made immutable are read-only variables
in Scala. This means their value remains unchanged throughout the
program. E.g.: val keyword.
Keywords are special words for a programming language that have some predefined actions in the programming. Thus, these keywords cannot be used as names for defining objects, classes, functions, variables, etc. The compiler will throw an error if we try to use keywords as identifiers.
Scala programming languages also
consist of a set of keywords to help in the efficient working of the program.
There are in total 39 keywords present
in Scala. Here is a list of all keywords in Scala,
In Scala programming language everything is an object. Even data types are treated as objects and have some method that performs operations of the data stored by them.
So, all values have a type,
including numerical value, classes and functions. The diagram below illustrates
a subset of the type hierarchy.
Any
is the parent data type (supertype) of all types, also called the
top type. It defines certain universal methods such as equals, hash Code
, and toString
.
Any
has two direct subclasses: AnyVal
and AnyRef
.
A)
AnyVal
represents 9 non-null
able value types which are : Double
, Float
, Long
, Int
, Short
, Byte
, Char
, Unit
, and Boolean
. Unit
is a value type which
carries no meaningful information.
B)
AnyRef
represents non-value
reference types. Every user-defined type in Scala is a subtype of AnyRef
. If Scala is used in the
context of a Java runtime environment, AnyRef
corresponds to java.lang.Object
.
There are two important types that are at the bottom of the hierarchy. They are
a) Nothing & b) Null.
The type at the bottom of the
hierarchy that is a subtype of all the types in Scala is Nothing. There is no
value of this type.
Null type is subtype of reference types (for all subtypes of AnyRef type).