class Student(var sal:Float)
{
  var sname:String?=null;
  var sid:Int=0;
  
   
   constructor(name:String,id:Int):this(0.0f)
   {
     sname=name;
     sid=id;
   }
   constructor(name:String):this(0.0f)
   {
     sname=name;
    // sid=id;
   }
   constructor(sid:Int):this(0.0f)
   {
    // sname=name;
    this.sid=sid;
   }
   fun displa()
   {
     println("Sname="+sname+",sid="+sid);
   }
}

fun main()
{
  var s1=Student("GIET",156);
  s1.displa();
  
  
  var s2=Student("GIET");
  s2.displa();
  
  var s3=Student(489);
  s3.displa();
} 
by

Kotlin Online Compiler

Write, Run & Share Kotlin code online using OneCompiler's Kotlin online compiler for free. It's one of the robust, feature-rich online compilers for Kotlin language. Getting started with the OneCompiler's Kotlin editor is easy and fast. The editor shows sample boilerplate code when you choose language as Kotlin and start coding.