1.

What are different types of Scala variables?

Answer»

It is well known that variables are merely RESERVED memory locations for storing values. In SCALA, variables are MAINLY of two types:  

  • Mutable Variables: These are variables whose VALUE is capable of CHANGING and the var keyword is used to declare these variables.

Syntax:  

 var Variable_name: Data_type = "value";

Example: 

 var Company: String = "InterviewBit”;
  • Immutable Variables: These are variables whose value is not capable of changing and the val keyword is used to declare these variables.

Syntax: 

 var Variable_name: Data_type = "value";

Example: 

 val Company: String = "InterviewBit";


Discussion

No Comment Found