Which of the following statements about constructors are tru

Which of the following statements about constructors are true?

1)A constructor is declared without a return type.

2) A constructor can be used instead of fields to represent the data inside a class.

3) A class can have many methods but only one constructor.

4)Constructors are considered bad programming style and should be avoided.

5)A constructor is a special method that creates an object and initializes its state.

6)A constructor wastes memory in the computer so it should be used sparingly.

7)A constructor is the code that is called when you use the \'new\' keyword.

(order shuffled)

Please list all the numbers that apply Thank You!

1)A constructor is declared without a return type.

2) A constructor can be used instead of fields to represent the data inside a class.

3) A class can have many methods but only one constructor.

4)Constructors are considered bad programming style and should be avoided.

5)A constructor is a special method that creates an object and initializes its state.

6)A constructor wastes memory in the computer so it should be used sparingly.

7)A constructor is the code that is called when you use the \'new\' keyword.

(order shuffled)

Solution

1)A constructor is declared without a return type. True. A constructor will not have a return type, and will not return anything..

2) A constructor can be used instead of fields to represent the data inside a class. False.

3) A class can have many methods but only one constructor. False. A class may have multiplie constructors, the concept of constructor overloading.

4)Constructors are considered bad programming style and should be avoided. False. Constructors are a good programming style.

5)A constructor is a special method that creates an object and initializes its state. True.

6)A constructor wastes memory in the computer so it should be used sparingly. False.

7)A constructor is the code that is called when you use the \'new\' keyword. True.

(order shuffled)

Which of the following statements about constructors are true? 1)A constructor is declared without a return type. 2) A constructor can be used instead of fields

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site