Multiple choice

Consider the following program code. class person { private string name; private int age; void person() { name=Raju; } talk() { System.out.println(Hello I am + name); } } Which constructor has been wrongly defined?

  1. class person()

  2. talk()

  3. person()

  4. private int age;

  5. none of these

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

This is a constructor since the class is also person and the constructors have the same names as that of their classes. It is wrongly defined in the program as void is used before constructor which is not allowed.