当前位置:网站首页>Scala language learning-08-abstract classes
Scala language learning-08-abstract classes
2022-07-06 07:25:00 【Sunshine clover lxgzxj】
One 、 Personal understanding
(1) Constants and variables in abstract classes are allowed to be uninitialized , A defined method may not write a method body .
(2) It is not allowed to create instances of abstract classes , Otherwise, it will prompt you to report an error .
(3) Abstract classes do not allow multiple inheritance , That is, a class can only inherit one abstract class .
Two 、 Test code
object TestAbstractClass {
def main(args: Array[String]): Unit = {
val ClassStudent: Student = new Student
ClassStudent.Eat()
println(ClassStudent.age)
println(ClassStudent.name)
}
}
abstract class Person{
// Abstract properties can be uninitialized
val name: String
var age: Int
// Abstract methods may not define method bodies
def Eat(): Unit
}
// Abstract class inheritance
class Student extends Person{
override val name: String = "Czg"
override var age = 12
override def Eat(): Unit = {
println("Student Eat !!!")
}
}
3、 ... and 、 test result
Student Eat !!!
12
Czg
边栏推荐
- First knowledge of OpenGL es learning (1)
- [MySQL learning notes 32] mvcc
- Excel的相关操作
- (4) Web security | penetration testing | network security web site source code and related analysis
- Set picture annotation in markdown
- If Jerry's Bluetooth device wants to send data to the mobile phone, the mobile phone needs to open the notify channel first [article]
- word中如何删除某符号前面或后面所有的文字
- Solution to the problem of breakthrough in OWASP juice shop shooting range
- Relevant introduction of clip image
- Leetcode35. search the insertion position (simple, find the insertion position, different writing methods)
猜你喜欢
![Ble of Jerry [chapter]](/img/00/27486ad68bf491997d10e387c32dd4.png)
Ble of Jerry [chapter]

Week6 weekly report

SSM学习
![Ble of Jerry [chapter]](/img/ed/32a5d045af8876d7b420ae9058534f.png)
Ble of Jerry [chapter]

Go learning --- use reflection to judge whether the value is valid

1091: two or three things in childhood (multi instance test)

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

Raspberry pie 3B update VIM

How Navicat imports MySQL scripts

Idea console color log
随机推荐
Wechat official account infinite callback authorization system source code, launched in the whole network
[JDBC] quick start tutorial
树莓派串口登录与SSH登录方法
You deserve this high-value open-source third-party Netease cloud music player
Multithreading and concurrent programming (2)
Leetcode 78: subset
位运算异或
【MySQL学习笔记32】mvcc
Do you really think binary search is easy
word怎么只删除英语保留汉语或删除汉语保留英文
Raspberry pie 3B update VIM
The way to learn go (II) basic types, variables and constants
Ble of Jerry [chapter]
Sélectionnez toutes les lignes avec un symbole dans Word et changez - les en titre
chrome查看页面fps
Typescript interface and the use of generics
Uni app practical project
navicat如何导入MySQL脚本
word中把帶有某個符號的行全部選中,更改為標題
Methods for JS object to obtain attributes (. And [] methods)