Computer Applications
Answer
| Constructor | Function |
|---|---|
| Constructor is a block of code that initializes a newly created object. | Function is a group of statements that can be called at any point in the program using its name to perform a specific task. |
| Constructor has the same name as class name. | Function should have a different name than class name. |
| Constructor has no return type not even void. | Function requires a valid return type. |
Related Questions
Assertion: A class can have multiple constructors.
Reason: Multiple constructors are defined with same set of arguments.
- Assertion is true, Reason is false.
- Both assertion and Reason are false.
- Both assertion and Reason are true.
- Assertion is false, Reason is true.
Name the following:
(a) Method with the same name as of the class and is invoked every time an object is created.
(b) Keyword to access the classes of a package.