Login using Social Account
     Continue with GoogleLogin using your credentials
new
keyword.Example:
class Car(makeOfCar: String, modelOfCar: String, yearOfCar: Int) {
var make: String = makeOfCar;
var model: String = modelOfCar;
var year: Int = yearOfCar;
var color = "";
def changeColor(colorOfCar: String) {
color = colorOfCar;
println ("New color of car:" + color);
}
}
object Demo {
def main(args: Array[String]) {
var car1 = new Car("Honda", "City", 1996);
var car2 = new Car("Honda", "Accord", 1999);
var car3 = new Car("Honda", "Amaze", 2015);
println("Car details:" + car1.make + " " + car1.model + " " + car1.year + " " + car1.color)
println("Car details:" + car2.make + " " + car2.model + " " + car2.year + " " + car2.color)
println("Car details:" + car3.make + " " + car3.model + " " + car3.year + " " + car3.color)
}
}
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
No hints are availble for this assesment
Answer is not availble for this assesment
Loading comments...