Professional Documents
Culture Documents
Theoretical Approach:
//creating object
object Demo //Demo is object Name
{
//declaring method
def main(args : Array[String])
{
//With declaration of Data types
var myVar: Int =10;
val myVal: String = “Hello scala with datatype decleration”;
//Without declaration of data type
var myVar1 = 20;
val myVal1 = “Hello scala with datatype declaration”;
//method1 to print result
println(myVar); println(myVal);
//method2 to print result
println (myVar1);
println (myVal1);
}
}
Expected Output: 10
Hello scala with datatype decleration.
20
Hello scala without datatype decleration.
Actual Output:
Task 02: Create an object named “scala”, take a variable “value” and assign the value ‘50’.
check if the value is equal to 20 so display “value is 20” , value is equal to 25 so display “value
is 25”, value is equal to 40 so display “value is 40”, either display “No match Found”.
Theoretical approached:
//Creating Object
object scala //Scala is a object name
{
//calling main method
def main(args : Array[String])
{
//Take a variable
var value : Int = 50;
}
}
Expected Output: No Match found
Practical Approached:
Actual Output:
Task 03: Write a program in scala to print infinite even number from 10.
Theoretical Approched:
//Creating Object
object MainObject //MainObject is object name
{
//Calling method
def main(args : Array[String])
{ //Take a variable
var a = 10;
do {
println(a);
a =a+2; //Incrementation
}
while(true)
}
}
Expected Output:
10
12
14
16
18
…………
Ctrl+z //To stop excutetion program
Practical Approached:
Actual Output:
Result:
The theoretical approach and practical approached is exact same and actual
and expected output is also exactly same.
Conclusion:
From this experiment I concluded that, Actual and Expected output is
matched hence the objective this practical or experimentation is successfully
completed.