Differentiate constructor and a method and how are it be
used?
Answer Posted / pranab dutta
A constructor is a member function of a class that is used
to create objects of that class where as a method is an
ordinary member function of a class.
Constructor has the same name as the class itself and
Member has its own name.
A Constructor has no return type, and is invoked using the
new operator.. Whereas a Member has a return type (which
may be void), and is invoked using the dot operator.
Is This Answer Correct ? | 8 Yes | 1 No |
Post New Answer View All Answers
what happens when a thread cannot acquire a lock on an object? : Java thread
What is default switch case? Give example.
Can a final variable be null?
Can we have more than one package statement in the source file?
What is overloading and overriding in java?
What do you understand by weak reference?
What are data structures in java?
What is a line break?
How many types of keywords are there?
What is the difference between serializable and externalizable interface?
Can a private method be declared as static?
What is api data?
What value is a variable of the string type automatically initialized?
Can we have two main methods in a java class?
What is the difference between a local variable and an instance variable?