Hi in CCA 175 spark using scala you have override toString function does its a inbuild function?

cca-175
scala
#1

Hi in CCA 175 spark using scala you have override toString function does its a inbuild function ???
Object oriented topic

0 Likes

#2

@Prasanna_Tirupathi

If you are asking about lecture 7.Object Oriented Concepts-Classes of Section2:Scala Fundamentals in CCA175 - Spark and Hadoop Developer Certification - Scala udemy course.

I hope you will get some clarity by below explanation.

class Example(arg: String) {  
}

In the above Scala code i have created class with name Example & passed 1 argument with name arg but not defined any thing inside it.

sca

I have compiled it.created new object Name.And passed object,object.toString() to separate println statements which are giving same output which is calssname@someHexNumber.

As we did not defined toString method for our object it will inheret toString from one of its parent class.If we did not defined in any parent class also it will inherent from Class called
ANY(which is called basic abstract class or root class in scala).

sc

In the above image in order to get values of the object we had overridden toString method in class level itself.

0 Likes