sitaram


{ City }
< Country > india
* Profession *
User No # 72474
Total Questions Posted # 0
Total Answers Posted # 58

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 281
Users Marked my Answers as Wrong # 95
Questions / { sitaram }
Questions Answers Category Views Company eMail




Answers / { sitaram }

Question { Wipro, 12765 }

What is an abstract class?


Answer

abstract class is class. we can't create the instantiate the
object of abstract class. In abstract class contains
concrete and abstract methods.when ever we can implement the
abstract methods. The current class will extends the
abstract class.

Is This Answer Correct ?    0 Yes 1 No

Question { RazorSight, 12273 }

How can we find size of the object ?


Answer

we don't have any method for to identify the size of object
in java.

Is This Answer Correct ?    0 Yes 2 No


Question { Wipro, 9923 }

Can multiple catch statements be used in exceptions ?


Answer

yes, multiple exceptions are possible.
we can write the program like this.

try{
}
catch(ArrayOutofBoundException e){ // Child Class.
}
----
catch(Exception e){ //parent class
}

Is This Answer Correct ?    0 Yes 1 No

Question { Wipro, 2736 }

How to know the host from which Applet is originated?


Answer

AppletViewer is taking care of applets.

Is This Answer Correct ?    0 Yes 1 No

Question { HCL, 4921 }

What is the GregorianCalendar class?


Answer

GregorianCalendar is a concrete subclass of Calendar and
provides the standard calendar used by most of the world.

Is This Answer Correct ?    0 Yes 0 No

Question { Persistent, 31731 }

what do you meant by Runtime Polymorphism?


Answer

The object is binded at the time of run-time is called
runtime Polymorphism.

Is This Answer Correct ?    0 Yes 0 No

Question { TCS, 149472 }

Difference between array and arraylist.


Answer

Array is static,only one data type values are storing. Size
Does not grow, its fixed

ArrayList is dynamic,different data type values are storing.
By adding values, it grows

Is This Answer Correct ?    3 Yes 1 No

Question { IBM, 7567 }

which class to use when concatenating
strings in a loop.


Answer

string buffer and string builder classes are used to
concatenate the two or more strings in a loop.

Is This Answer Correct ?    1 Yes 0 No

Question { Satyam, 9501 }

what are depricated methods ?


Answer

we can't use the deprecated method in the latest versions.
For example: Thread.stop()--> deprecated method.

Is This Answer Correct ?    0 Yes 0 No

Question { Polaris, 4445 }

What is store procedure?and how do u take the values from
database and run in scripts?


Answer

Store Procedure is a procedure. it may or maynot return values.
Ex: create procedure procedure_name

begin

start

end.

Is This Answer Correct ?    0 Yes 0 No

Question { Yardi, 320487 }

how to find the second highest salary from emp table?


Answer

query:
======
select e.name,e.salary from emp e where &n =(select
count(distinct ee.salary) from emp ee where e.salary<=e.salary)

after run enter n value:

if 2 enter second max salary will come
if 3 enter third max salary will come.

otherwise, we can write below

select e.name,e.salary from emp e where 2 =(select
count(distinct ee.salary) from emp ee where e.salary<=e.salary)

Is This Answer Correct ?    0 Yes 0 No

Question { Sapient, 5180 }

Input :14000 Output : hundred and fourteen thousand.(wrong)
Desired output : fourteen hundred thousand.


Answer

public class Converter
{
private double getPlace( String number ){
switch( number.length() ){
case 1:
return DefinePlace.UNITS;
case 2:
return DefinePlace.TENS;
case 3:
return DefinePlace.HUNDREDS;
case 4:
return DefinePlace.THOUSANDS;
case 5:
return DefinePlace.TENTHOUSANDS;
case 6:
return DefinePlace.LAKHS;
case 7:
return DefinePlace.TENLAKHS;
case 8:
return DefinePlace.CRORES;
case 9:
return DefinePlace.TENCRORES;
}//switch
return 0.0;
}// getPlace

private String getWord( int number ){
switch( number ){
case 1:
return "One";
case 2:
return "Two";
case 3:
return "Three";
case 4:
return "Four";
case 5:
return "Five";
case 6:
return "Six";
case 7:
return "Seven";
case 8:
return "Eight";
case 9:
return "Nine";
case 0:
return "Zero";
case 10:
return "Ten";
case 11:
return "Eleven";
case 12:
return "Tweleve";
case 13:
return "Thirteen";
case 14:
return "Forteen";
case 15:
return "Fifteen";
case 16:
return "Sixteen";
case 17:
return "Seventeen";
case 18:
return "Eighteen";
case 19:
return "Ninteen";
case 20:
return "Twenty";
case 30:
return "Thirty";
case 40:
return "Forty";
case 50:
return "Fifty";
case 60:
return "Sixty";
case 70:
return "Seventy";
case 80:
return "Eighty";
case 90:
return "Ninty";
case 100:
return "Hundred";
} //switch
return "";
} //getWord

private String cleanNumber( String number ){
String cleanedNumber = "";

cleanedNumber = number.replace( '.', ' ' ).replaceAll( " ",
"" );
cleanedNumber = cleanedNumber.replace( ',', ' '
).replaceAll( " ", "" );
if( cleanedNumber.startsWith( "0" ) )
cleanedNumber = cleanedNumber.replaceFirst( "0", "" );

return cleanedNumber;
} //cleanNumber

public String convertNumber( String number ){
number = cleanNumber( number );
double num = 0.0;
try{
num = Double.parseDouble( number );
}catch( Exception e ){
return "Invalid Number Sent to Convert";
} //catch

String returnValue = "";
while( num > 0 ){
number = "" + (int)num;
double place = getPlace(number);
if( place == DefinePlace.TENS || place ==
DefinePlace.TENTHOUSANDS || place == DefinePlace.TENLAKHS ||
place == DefinePlace.TENCRORES ){
int subNum = Integer.parseInt( number.charAt(0) + "" +
number.charAt(1) );

if( subNum >= 21 && (subNum%10) != 0 ){
returnValue += getWord( Integer.parseInt( "" +
number.charAt(0) ) * 10 ) + " " + getWord( subNum%10 ) ;
} //if
else{
returnValue += getWord(subNum);
}//else

if( place == DefinePlace.TENS ){
num = 0;
}//if
else if( place == DefinePlace.TENTHOUSANDS ){
num -= subNum * DefinePlace.THOUSANDS;
returnValue += " Thousands ";
}//if
else if( place == DefinePlace.TENLAKHS ){
num -= subNum * DefinePlace.LAKHS;
returnValue += " Lakhs ";
}//if
else if( place == DefinePlace.TENCRORES ){
num -= subNum * DefinePlace.CRORES;
returnValue += " Crores ";
}//if
}//if
else{
int subNum = Integer.parseInt( "" + number.charAt(0) );

returnValue += getWord( subNum );
if( place == DefinePlace.UNITS ){
num = 0;
}//if
else if( place == DefinePlace.HUNDREDS ){
num -= subNum * DefinePlace.HUNDREDS;
returnValue += " Hundred ";
}//if
else if( place == DefinePlace.THOUSANDS ){
num -= subNum * DefinePlace.THOUSANDS;
returnValue += " Thousand ";
}//if
else if( place == DefinePlace.LAKHS ){
num -= subNum * DefinePlace.LAKHS;
returnValue += " Lakh ";
}//if
else if( place == DefinePlace.CRORES ){
num -= subNum * DefinePlace.CRORES;
returnValue += " Crore ";
}//if
}//else
}//while
return returnValue;
}//convert number

public static void main( String args[] ){
Converter cv = new Converter();

if( args.length >= 1 )
{
for( int i=0; i System.out.println( "Given Number : " + args[i] +
"\nConverted: " + cv.convertNumber(args[i]) + "\n\n" );
System.exit(0);
}

System.out.println( "Given Number : 14000\nConverted: " +
cv.convertNumber("14000") + "\n\n" );
}//main
} //class

class DefinePlace{
public static final double UNITS = 1;
public static final double TENS = 10 * UNITS;
public static final double HUNDREDS = 10 * TENS;
public static final double THOUSANDS = 10 * HUNDREDS;
public static final double TENTHOUSANDS = 10 * THOUSANDS;
public static final double LAKHS = 10 * TENTHOUSANDS;
public static final double TENLAKHS = 10 * LAKHS;
public static final double CRORES = 10 * TENLAKHS;
public static final double TENCRORES = 10 * CRORES;
} //class

Is This Answer Correct ?    4 Yes 0 No

Question { Satyam, 13972 }

Is it possible to create mulitple instance of one Action
Class in struts?


Answer

Only one instance of action class is created per
application, as we know for each request container will
create separate thread hence for 100 request 100 theads will
be creates and that 100 request can handle
concurrently...(which is executing execute() method of
action class's single instance) i.e. you can say class
variable of action class is not at all thead safe.

Is This Answer Correct ?    4 Yes 1 No

Question { iGate, 64442 }

life cycle of struts?


Answer

Please find the below ural for struts life cycle digram.
http://www.ibm.com/developerworks/java/library/j-seam1/lifecycle.gif.

suppose one form having name,age two fields and one submit
button. when ever enter the two fields and submit button.
the request goes to web.xml. the request check in the struts
config.file. the related form bean and action class will be
executing. then related redirect page.

Is This Answer Correct ?    5 Yes 8 No

Question { TCS, 10385 }

If we close the browser,when the specific user session is
active.Again if we open browse how to retrive it same
user??what code i have to da???


Answer

we can mention the sessiontimeout(5min) in the
web.xml.suppose user will close the browser in the middle of
work. after 2 min again open the same site.
automatically,session is active.

Is This Answer Correct ?    2 Yes 0 No

 [1]   2   3   4    Next