A student wrote code that does not compile, and we were asked to do a code review. Find the error in the code and fix it so that the code works correctly. In this code, the student tried to create a base class with a private property and function, as well as a successor class that calls the private function of the base class.
Computer scienceProgramming languagesKotlinObject-oriented programmingObject-oriented programming basic
Visibility for classes, packages, and modules
Rewiew code
Report a typo
Write a program in Kotlin
open class BrokenPrivateBase {
private val brokenPrivateTaskProperty: String = "Private property"
private fun brokenPrivateTaskFunction() {
println("Private function")
}
}
class BrokenPrivateDerived : BrokenPrivateBase() {
fun showBrokenPrivateElements() {
println(brokenPrivateTaskProperty)
brokenPrivateTaskFunction()
}
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.