English

State the difference between constructor and method. - Computer Applications

Advertisements
Advertisements

Questions

State the difference between constructor and method. 

Give differences between a constructor and a method.

Distinguish Between

Solution

S. No. Constructor Function/Method
1. The constructor is named the same as the class name. A function's name differs from its class name.
2. Constructors do not return any value, including void. Functions may or may not return a value.
3. Constructors are often public. A method can be public or private.
4. The constructor is simply used to set data members. A method is utilized to execute mathematical or logical tasks.
shaalaa.com
  Is there an error in this question or solution?
Chapter 7: Constructors - EXERCISES [Page 418]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 7 Constructors
EXERCISES | Q V. 6. | Page 418
Avichal Computer Applications [English] Class 10 ICSE
Chapter 7 Constructors
Review Insight | Q 8. | Page 415
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×