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
How will you get the platform dependent values like line separator, path separator, etc., ?
Explain the reason behind ending a program with a system.exit(0)?
State two differences between C and Java.
Is object a data type?
What is the difference between jdk and jre?
What is a boolean output?
What are generic methods?
what is instanceof operator used in java?
What happens to a static var that is defined within a method of a class?
Difference between throw and throws?
Which method you will use to create a new file to store some log data. Each time a new log entry is necessary, write string to the file in java ?
Explain the difference between protected and default access.
What one should take care of, while serializing the object?
Difference between association, composition and aggregation?
What is static class