Quick Print – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
siteicon
Solved Problem Solved Problem#JAVA#7239

Problem Statement - Constructor Vs. Function

Differentiate between constructor and function.

Solution

The constructor of a class is invoked automatically during object creation while a function is invoked manually after object creation.

A constructor is invoked only once while a function can be invoked multiple times.

A constructor has the same name as the class in which it is defined while a function can have any name.