scala> // An Abstract Class cannot be Instantiated #219
scala> // Abstract key word is Mandatory for an abstract class
scala> abstract class Subject {
| //These are abstract methods
| // as it do not have any definition, but only
| // declaration #220
| def name: String
| def mark: Int
| }
defined class Subject
scala>
scala> //We cannot instantiate an abstract class
scala> val sub = new Subject()
<console>:24: error: class Subject is abstract; cannot be instantiated
val sub = new Subject()
^
scala>
scala> //This does not compile..as we do not give the
scala> // abstract keyword
scala> class Subject {
| //These are abstract methods
| // as it do not have any definition, but only
| // declaration #220
| //abstract keyword is optional for a method
| def name: String
| def mark: Int
| }
<console>:11: error: class Subject needs to be abstract, since:
it has 2 unimplemented members.
/** As seen from class Subject, the missing signatures are as follows.
* For convenience, these are usable as stub implementations.
*/
def mark: Int = ???
def name: String = ???
class Subject {
^