Differentiate constructor and a method and how are it be
used?

Answer Posted / teju

constructor: It is one special member function.it has name same like class .it does not have any return type.it gets executed when we create an object of class and invokes implicitly. constructor is used to initialize the variables ,start the thread

method:
it gets executed explicitly when object is created . it has return type .
method is used to invoke the task or block of code

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between compile-time polymorphism and runtime polymorphism?

574


What is the difference between inheritance and encapsulation?

601


What will happen if a thrown exception is not handled?

570


Name few java 8 annotations ?

576


What is the old name of java?

511






What is the difference between integer parseint and integer valueof?

559


What is immutable data?

588


How do you convert bytes to character in java?

539


How do you sort arrays in java?

532


How many static init can you have?

696


What is a lock or purpose of locks in java?

601


What do you mean by formatting?

555


Program to Find the second largest element in an array.

595


Why string is immutable with example?

540


What is classname class in java?

544