Scala

You are currently auditing this course.
10 / 53

Scala - Program Structure

A Scala program can be defined as a collection of objects that communicate by invoking each other’s methods.

Components of a Scala program:

Class - A class can be defined as a template/blueprint/structure that describes the behaviors/states that are related to the class.

Object - An object is an instance of a class and has states and behaviors. Example - A car has color, make, model as states and move, brake, as behaviors.

Methods - A method is a behavior of a class and hence of its instantiated objects. Methods have logic and code to manipulate the data and execute the action.

Fields - A field is state of a class and hence of its instantiated objects, which define properties of the objects. An object's state is created by the values assigned to these fields.

Closure - A closure is a function, which returns values depending on the input to it. Input is given via values assigned to variables declared outside this function.

Traits - A trait encapsulates method and field definitions, which can then be reused by mixing them into classes. Traits are used to define object types by specifying the signature of the supported methods.

Variables - Variables are placeholders for any attributes which need to be calculated, manipulated or assigned to. This is similar to any other programming language.

We will study about these building blocks in upcoming sessions.


No hints are availble for this assesment

Answer is not availble for this assesment

Loading comments...