GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  Manhattan Associates  >  Java
Go To First  |  Previous Question  |  Next Question 
 Java  |  Question 16 of 17    Print  
What is the better way of writing the Constructor with 2 parameters in the following code:

class Test {

int x,y;

Test(int a) {

//Code for very complex operations will be written
//in this place

x=a;
}

Test(int a, int b) {

//Code for very complex operations will be written
//in this place (same code as in above constructor)

x=a;
y=b;
}
}


  
Total Answers and Comments: 3 Last Update: August 02, 2005   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
May 02, 2005 16:30:06   #1  
wtf        

RE: What is the better way of writing the Constructor with 2 parameters in the following code:class Te...
I cant understand what they mean with that question.
Who knows the answer?

 
Is this answer useful? Yes | No
May 09, 2005 07:35:43   #2  
Hari        

RE: What is the better way of writing the Constructor with 2 parameters in the following code:class Te...
Test(int a int b) {
this(a);
this.y b;
}

 
Is this answer useful? Yes | No
August 02, 2005 05:21:49   #3  
Sumit Sengar        

RE: What is the better way of writing the Constructor with 2 parameters in the following code:class Te...
Test(int a int b)
{
this(a);
}

This is becoz assigning the value a to instance variable has already been done in one place so why to repeat it again in this constructor also.So the better way is to call the first 1 argument constructor using this keyword.

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape