Child class inherits the parent class to complete the parent class parameter of the Fill class person (Val name:string, Val age:int) {
println ("Father ' s constructor")
Val class = "First Class"
def read = "Ten hours"
Override def toString = "I am a Goodperson"
}
Class Stu (Namestu:string,agestu:int,val sex:string) Extendsperson (Namestu,agestu)
{
println ("Son ' s constructor")
Override Val Class = "I ' m a student in FirstClass"
Override def toString = "I am a good student"
}
Object Uni {
def main (args:array[string]): Unit = {
Val Stu =new Stu ("Stu1", 20, "male")
println (Stu. Class)
println (stu.tostring ())
}
}
Run results
Father ' s constructor
Son ' s constructor
I ' m a student in first class
I am a good student
Now is the best opportunity to learn big data, do not spend a penny can become big Data master, achieve 500,000 annual salary dream.
Liaoliang's first Chinese Dream: Free for the whole society to train 1 million outstanding big data practitioners!
If you are interested please click on this link to go to Big data learning
Http://blog.sina.com.cn/s/blog_8fbd39ee0102vto3.html
If you do feel that video tutorials are helpful, you can donate big data, Internet +, online, Industry 4.0, micro-marketing, mobile internet and other free combat courses through Liaoliang Teacher's number 18610086859
You can also focus on the DT Big Data dream factory through the following two-dimensional code
From big Data rookie to Master's Journey Scala 11th lecture extends