What does the following code do? public class Example { private int var;…

PYQ RPSC Programmer 2024

What does the following code do? public class Example { private int var; public Example(int var) { this.var = var; } }

  1. A.

    Creates a new instance of the class Example.

  2. B.

    Throws an error because this cannot be used.

  3. C.

    Assigns the parameter var to the instance variable var.

  4. D.

    Compilation Error.

  5. E.

    Question not attempted

Attempted by 113 students.

Sign up free to check your answer

Sign up free

Explore the full course: Rpsc Programmer

Loading lesson…