ICSE Class 10 Computer Applications
Question 29 of 30
Solved 2025 Specimen Paper ICSE Class 10 Computer Applications — Question 29
Back to all questions 29
Question The type of constructors used in the above program segment are:
- Default constructor
- Parameterized constructor
Explanation:
The types of constructors used in the given program are:
1. Default Constructor:
calculate() {
a = 0;
b = 0.0;
}- A default constructor is a constructor that does not take any parameters.
- It initializes the instance variables
aandbwith default values (0and0.0respectively).
2. Parameterized Constructor:
calculate(int x, double y) {
a = x;
b = y;
}- A parameterized constructor is a constructor that takes arguments (
int xanddouble yin this case). - It allows for initializing the instance variables
aandbwith specific values provided during object creation.