-
-
Save pradhuman7d1/22f03fbf3c1ad1b49e43ea3eb641f958 to your computer and use it in GitHub Desktop.
scala-abstract-trait
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 does abstract class means? | |
A. Abstract class is one which declares variables or functions but does not initialize or define their body. | |
Q. What are traits? | |
A. Traits are like interfaces the simply define some values or functions and then inplemented into classes. Their can also be concrete methods. | |
Q. Why we use traits when we can do the same with abstract class? | |
A. We use trait because we can use multiple traits in one class whereas only one abstract class can be used. | |
Q. What is the purpose of traits? | |
A. You can define multiple traits with different methods or attributes and then implement all of the together in a 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. How we implement multiple traits in a class? | |
a. class c(args) extends trait1 extends trait2 {..body..} | |
b. class c(args) extends trait1 and trait2 {..body..} | |
c. class c(args) extends trait1 with trait2 {..body..} | |
d. class c(args) with trait1 extends trait2 {..body..} | |
A. c. class c(args) extends trait1 with trait2 {..body..} | |
Q. How an abstract class is made? | |
a. class c(args) abstract {..body..} | |
b. class c(args) :abstract {..body..} | |
c. abstract: class c(args) {..body..} | |
d. abstract class c(args) {..body..} | |
A. d. abstract class c(args) {..body..} | |
Q. How we define a trait? | |
a. trait class t {..body..} | |
b. trait t {..body..} | |
c. class trait t {..body..} | |
d. trait (args) {..body..} | |
A. b. trait t {..body..} | |
Q. How many classes can be implemented using an abstract class? | |
a. only 1 | |
b. upto 2 | |
c. as much as you want | |
A. c. as much as you want |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment