Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


What is the difference between constructor and method?

Answers were Sorted based on User's Feedback



What is the difference between constructor and method?..

Answer / shadow

Constructor will be automatically invoked when an object is
created whereas method has to be called explicitly. ...!

$HADOW

Is This Answer Correct ?    13 Yes 3 No

What is the difference between constructor and method?..

Answer / pinky

Constructor doesnt return anything. where as method may or
may not return data or value

Is This Answer Correct ?    6 Yes 0 No

What is the difference between constructor and method?..

Answer / sameer inamdar

Constructor must have the same as the class name,
whereas we can give any name to the method.
Constructor doesnt have any return type not even void,
whereas method must have valid return type or void if
nothing is return.
Constructor will implicitely invoke at the time of
object creation, whereas method must invoke explicitely
with the object.

Is This Answer Correct ?    3 Yes 0 No

What is the difference between constructor and method?..

Answer / rattaiah addanki

methods:
modifiers_list Return_type Method_name(Parameter_list)
public void withdraw(int accno)
{
business logic
}

1) method is used to provide the business logic of the project
2) the methods are executed whenever wee are calling that
methods.
3) every method having return type.

Constructors:-
Modifiers_list Constructor_name(parameters)
ex:- public Test(int i)


1) where as constructors are used to create object.
2) the constructor is executed then only object is created.
3) at the time of object creation the constructors are
executed no need of calling.
4) if we want to execute any code at time of the object
creation then we should go for constructors concept.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Core Java Interview Questions

what is webservices

5 Answers   Consultancy, Mind Tree,


What is ph and buffers?

0 Answers  


Difference between a Canvas and a Scroll Pane?.

1 Answers   NIIT,


can we have virtual functions in java?

11 Answers   Wipro,


what do you mean by java annotations?

0 Answers  


What is the difference between @before and @beforeclass annotation?

0 Answers  


What is a type parameter in java?

0 Answers  


Differentiate between vector and array list.

0 Answers  


What is the purpose of a volatile variable?

0 Answers  


What is difference between Iterator and for loop

9 Answers   HP,


What are the main uses of the super keyword?

0 Answers  


What are the different types of inner classes?

0 Answers  


Categories