title: How to write getters and setters in kotlin?
body: <p>I am new to kotlin and building a quiz app. I don't understand How do I write this java code into Kotlin? Especially the getters and setters? Also how to create both default and parameterized constructor in Kotlin?</p>
  
  <p>What I did is This:</p>
  
  <pre><code>class Question {
  
      var question: String
      var opt1: String
      var opt2: String
      var opt3: String
      var answerno: Int
  
      constructor(question: String, opt1: String, opt2: String, opt3: String, answerno: Int) {
          this.question = question
          this.answerno = answerno
          this.opt1 = opt1
          this.opt2 = opt2
          this.opt3 = opt3
      }
  }
  </code></pre>
  
  <p>Java Code Here:</p>
  
  <pre><code>public class Question {
      private String question;
      private String option1;
      private String option2;
      private String option3;
      private int answerNr;
      public Question() {
      }
      public Question(String question, String option1, String option2, String option3, int answerNr) {
          this.question = question;
          this.option1 = option1;
          this.option2 = option2;
          this.option3 = option3;
          this.answerNr = answerNr;
      }
      public String getQuestion() {
          return question;
      }
      public void setQuestion(String question) {
          this.question = question;
      }
      public String getOption1() {
          return option1;
      }
      public void setOption1(String option1) {
          this.option1 = option1;
      }
      public String getOption2() {
          return option2;
      }
      public void setOption2(String option2) {
          this.option2 = option2;
      }
      public String getOption3() {
          return option3;
      }
      public void setOption3(String option3) {
          this.option3 = option3;
      }
      public int getAnswerNr() {
          return answerNr;
      }
      public void setAnswerNr(int answerNr) {
          this.answerNr = answerNr;
      }
  }
  </code></pre>