answersLogoWhite

0


Best Answer

Two key points to remember about constructors are that they have no return type and their names must exactly match the class name.

Methods can have any names and can have any return types.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are the similarities between constructors and methods?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is different between constructor and method?

Constructors have no return type and their names must exactly match the class name. Apart from this constructors and methods are similar to one another.


What is the similarities between research methodology and research methods?

no


What is the Difference between virtual methods and non virtual methods in c sharp?

A function is a method that returns a value other than void. Methods includes functions, subroutines, constructors, destructors, and properties.


Which is the most usable method or constructor in java?

There is no comparison between methods and constructors. They are both present for a reason and each has its own purpose.


How can you identify a constructor from among any other methods in a class?

Constructors have the same identifier as that of the class, so if the name of your class is Book then your constructor must also be named Book. Constructors have no return type, not even void.


What are the similarities and differences between evaporation and distillation?

They are both methods which use heat to separate mixtures.


Similarities between graphical and simplex methods?

both are used to solve linear programming problems


What types of functions cannot be made virtual?

Static member functions, member function templates and constructors cannot be virtual.


What are similarities between mahatma Gandhi and Nelson Mandela?

They were civil rights leaders and used non violent methods of revolution.


What is factory methods?

Factory methods are merely a convention whereby static methods in a class return an instance of that class. The InetAddress class has no visible constructors. In InetAddress the 3 factory methods getLocalHost, getByName, getAllByName can be used to create instances of InetAddress.


Write a program that displays information about methods along with the parameters excluding the set and get method defined for implementing the properties in c sharp?

Not sure if the constructors should be counted as methods, thus, there are 2 methods below:GetMethodsOf() returns all methods, excluding the properties but including the constructorsGetRoutinesOf() similar to GetMethodsOf(), but also excluding the constructorsusing System.Reflection;/// /// generates a sequence of methodInfo of a type t, excluding the getters and the setters/// constructors are included/// /// /// static IEnumerable GetMethodsOf(Type t){foreach (MethodInfo info in t.GetMethods()){if (!info.Name.StartsWith("get_") && !info.Name.StartsWith("set_")){ // properties are filteredyield return info;}}}/// /// Similar to GetMethodsof(), but also excluding the constructors/// /// /// static IEnumerable GetRoutinesOf(Type t){foreach (MethodInfo info in GetMethodsOf(t)){if (!info.IsConstructor) // constructors are filteredyield return info;}}


Is php is package?

A package is a mechanism for organizing namespace, constructors, methods and fields. PHP is a technology in itself and contains quite a few packages