Call a method on a Super Class in Scala Last Updated : 05 Aug, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report This concept is used when we want to call super class method. So whenever a base and subclass have same named methods then to resolve ambiguity we use super keyword to call base class method. The keyword "super" came into this with the concept of Inheritance. Below is the example of call a method on a superclass. Example #1: Scala // Scala program to call a method // on a superclass in Scala /* Base class ComputerScience */ class ComputerScience { def read { println("I'm reading") } def write { println("I'm writing") } } /* Subclass Scala */ class Scala extends ComputerScience { // Note that readThanWrite() is only in Scala class def readThanWrite() { // Will invoke or call parent class read() method super.read // Will invoke or call parent class write() method super.write } } // Creating object object Geeks { // Main method def main(args: Array[String]) { var ob = new Scala(); // Calling readThanWrite() of Scala ob.readThanWrite(); } } Output: I'm reading I'm writing In above example, we are calling multiple method of super class by using super keyword. Example #2: Scala // Scala program to call a method // on a superclass in Scala /* Super class Person */ class Person { def message() { println("This is person class"); } } /* Subclass Student */ class Student extends Person { override def message() { println("This is student class") } // Note that display() is only in Student class def display() { // will invoke or call current class message() method message () // will invoke or call parent class message() method super.message } } /* Creating object */ object Geeks { // Main method def main(args: Array[String]) { var s = new Student(); // Calling display() of Student s.display(); } } Output: This is student class This is person class In the above example, we have seen that if we only call method message() then, the current class message() is invoked but with the use of super keyword, message() of super class could also be invoked. Comment More infoAdvertise with us Next Article Calling A Super Class Constructor in Scala D DivyaPareek Follow Improve Article Tags : Scala Scala-OOPS Similar Reads Scala | Methods to Call on a Map | Set-1 Prerequisite- Scala Map. In Scala there are foremost Methods to call on a Map. A Scala Method is a section of a class which has a designation, a signature, optionally a few annotations, and whatsoever byte-code. A function which is interpreted as a member of some Object is termed as a Method and the 12 min read Calling A Super Class Constructor in Scala Prerequisite - Scala ConstructorsIn Scala, Constructors are used to initialize an object's state and are executed at the time of object creation. There is a single primary constructor and all the other constructors must ultimately chain into it. When we define a subclass in Scala, we control the sup 3 min read Scala Int getClass() method with example The getClass() method is utilized to return the class of the given int number. Method Definition: (Number).getClass Return Type: It returns the class of the given number. Example #1: Scala // Scala program of Int getClass() // method // Creating object object GfG { // Main method def main(args:Array 1 min read Scala | Methods to Call Option The Option in Scala is referred to a carrier of single or no element for a stated type. When a method returns a value which can even be null then Option is utilized i.e, the method defined returns an instance of an Option, in place of returning a single object or a null. There are a few methods that 5 min read Scala Char getClass() method with example The getClass() method is utilized to return the run-time class representation of the stated object. Method Definition: def getClass(): Class[Char] Return Type: It returns the class of the stated object. Example: 1# Scala // Scala program of getClass() // method // Creating object object GfG { // Mai 1 min read Determine the class of a Scala object To determine the class of a Scala object we use getClass method. This method returns the Class details which is the parent Class of the instance. Below is the example to determine class of a Scala object. Calling method with argument - Example #1: Scala // Scala program to determine the class of a S 2 min read Like