-
-
Save pradhuman7d1/dea61702e863958c68435c9dbf0f67a3 to your computer and use it in GitHub Desktop.
scala-class-inheritance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q. What are classes? | |
A. A class is a block of code that contains declaration on some member variables and functions and then we create multiple objects for the class that assigns the values to the variables. | |
Q. What is inheritance? | |
A. Inheritance is the use of properties and variables of an existing class into a new class.(a new class inherits from old class) | |
Q. What is an object? | |
A. A variable that we create in our program using a class that we have created. That object contains the values corresponding to variables declared in the class. | |
Q. Why we use inheritance? | |
A. Inheritance is useful when we need to create multiple classes with some common attributes. So, we can inherit those values from a single class. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q. What is the basic structure of a class declaration? | |
a. class Bird(arg :datatype) {..body..} | |
b. Class Bird(arg :datatype) {..body..} | |
c. class Bird(datatype :arg) {..body..} | |
d. None of these | |
A. a. class Bird(arg :datatype) {..body..} | |
Q. What keyword is used to inherit from a class? | |
a. inherits | |
b. increases | |
c. implements | |
d. extends | |
A. d. extends | |
Q. What does "this" keyword signify ? | |
a. the argument passed in function inside a class | |
b. the attribute type of the class | |
c. the value of the attribute for that object | |
d. None of these | |
A. c. the value of the attribute for that object | |
Q. How we can prevent a attribute from direct access outside the class? | |
a. by using this keyword | |
b. by using my keyword | |
c. by using personal keyword | |
d. by using private keyword | |
A. d. by using private keyword |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment