java questions

Download java questions

If you can't read please download the document

Upload: sudeep-mishra

Post on 16-Sep-2015

92 views

Category:

Documents


10 download

DESCRIPTION

java programs

TRANSCRIPT

--------------------Dhivya1) compare two strings, if the characters in string 1 are present instring 2, then it should be put as such in output, else '+' should beput in output...ignore case difference.input 1:"New York" input 2:"NWYR" output:N+w+Y+r+ 2)inputSearchstring s1="GeniusRajkumarDev";String s2="Raj";String s3="Dev";Return 1 if s2 comes before s3 in searchstring else return 23) months between two dates4) intput="xyzwabcd"intput2=2;input3=4; output=bawz5)String input1="--this--is---"; String input2="--adsf--is---";return 1 if count and indexes of '-' in both the string is sameelse return 2---------------manisha1.Given integer arrayinput :int[] arr={2,3,54,1,6,7,7};Remove the duplicate elements and print sum of even numbers in the array..print -1 if arr contains only odd numbers2. given an integer 345 print it as 543..3. in a map, find the value corresponding to the largest keyinput{12:"hari",13:"krish",18:"mani"}output:,mani4. input1="abc2012345"input2="abc2112660"input 3=4here "abc20" refers to customer id and 12345 refers to the last month eb reading and 12660 refers to this month eb readingfind the difference between 12660 and 12345 and multiply itr by input3ie., output=(12660-12345)*45.Check if a string palindrome.Return 1 if the string is palindrome as well as it should have more than 1 unique vowels. else return -1Eg: nayan is a palidrome but only 1 unique vowel 'a' return -1Eg: naeyean return 1---------------yuvaranjani1) Given the first name and last name,hv to print the last name first then followed by "," and first character of the first name.Input: Steve jobsOutput: jobs,S2)Given two hashmap h1 with employee id and designation and hashmap h2 with id and salary, in a new Haspmap the manager id and salary with the increment of 5000 has to added and printed.Input: {1="analyst",2="manager"}Input2:{1=2000,2=5000}output:{2=10000}3)Given two string with "-".check whether the two strings has the "-" at same place.if same print 1,else 2.Input:"---abb---"Input2:"---dfg---"Output:14)Given array of intergers,print the sum of square of elements at the power of their indices.Input:{2,2,5}Output:285)Given array of string check whether all the elements contains only digits not any alaphabets.if condn satisfied print 1 else -1.Input:{"123","23.14","522"}output:1Input1:{"asd","123","42.20"}output:-1--------------sakthi1) reverse of a string input="1234" output="4321"2) input="flower.gif" output=gif3) months between two dates4) int[] a={12,14,2,26,35}find the difference b/w max and min values in arrayoutput:35-2=33.5)compare two strings, if the characters in string 1 are present instring 2, then it should be put as such in output, else '+' should beput in output...ignore case difference.input 1:"New York"input 2:"NWYR"output:N+w+Y+r+----------Hemnath1) input="14/12/2012" output=friday2) Given an array find the largest 'span'(span is the number of elements between two same digits)arr[]={1,4,2,1,4,1,5}Largest span=63) intput="xyzwabcd"intput2=2;input3=4; output=bawz4) password validation5) input={"1","2","3","4"}output=10input={"a","b"}output=-1;---------srinivasan1) reverse of a string input="1234" output="4321"2) arraylist1={ 1,2,3,4,5} arraylist2={ 6,7,8,9,10}size of both list should be sameoutput={6,2,8,4,10}3) Input:"---abb---"Input2:"---dfg---"Output:14) Given array of string check whether all the elements contains only digits not any alaphabets.if condn satisfied print 1 else -1.Input:{"123","23.14","522"}output:15) inputSearchstring s1="GeniusRajkumarDev";String s2="Raj";String s3="Dev";Return 1 if s2 comes before s3 in searchstring else return 2-------manohar1)inputSearchstring s1="GeniusRajkumarDev";String s2="Raj";String s3="Dev";Return 1 if s2 comes before s3 in searchstring else return 22) removing vowels in even positionintput=commitment;output=cmmitmnt3) count the number times the second word in second string occurs in first string-case sensitiveinput=hai hello hai where hai Hai;input2=what haioutput=3;4) return sum od non prime number intput=9;out put=1+4+6+8+9=28-------steffie1) inputSearchstring s1="GeniusRajkumarDev";String s2="Raj";String s3="Dev";Return 1 if s2 comes before s3 in searchstring else return 22)input1=130input2=150find the palindrom nos b/w the range and find the sumoutput=2723) range 0-255input=255.55.33.155output = trueinput=300.55.33.155output = false4) String a[]={"abx-23-78","des-90-12","ghi-45-23"};find the sum of marks in each string.Find the max mark and find the corresponding name.output:des5) find if a charcter has repeated 3 consequetive timesinput1:"aaabbccc"ouput1=2;----------swathi1) inputSearchstring s1="GeniusRajkumarDev";String s2="Raj";String s3="Dev";Return 1 if s2 comes before s3 in searchstring else return 22) reverse of a number3)input={1,4,5,2,8,3}find difference b/w adjacent numbers and return index of biggest number 8-2=6output=index of 84) input="hai this is cognizant academy"input2="hello this is a trainee"find the occurance of the second word from the second string in the first stringoutput=15) no of days b/w two dates---------vasanth1)input1="ABC2012333" (STRING) first five chars are consumer nos and next five are units for current bill input2="ABC2012444" (STRING) first five chars are consumer nos and next five are units for current bill INPUT3=4 (INT) charge per unit output= (input2-input1) * input3 output=(444-333)*4;2)ID validation3)compare two strings, if the characters in string 1 are present instring 2, then it should be put as such in output, else '+' should beput in output...ignore case difference.input 1:"New York"input 2:"NWYR"output:N+w+Y+r+4)What will be the DAY of current date in next year-----------------------Brabanjana--------------------------1)Searchstring s1="GeniusRajkumarDev";String s2="Raj";String s3="Dev";Return 1 if s2 comes before s3 in searchstring else return 22)compare two strings, if the characters in string 1 are present instring 2, then it should be put as such in output, else '+' should beput in output...ignore case difference.input 1:"New York"input 2:"NWYR"output:N+w+Y+r+3)input1=130input2=150find the palindrom nos b/w the range and find the sumoutput=2724)No :of months between two dates5)Input: HashMap 1:HashMap 2:Increment the salary of Managers by 50006)Input:StringOutput:intGet all the numbers from the string and return the sum.Input"123gdf"Output:67)Number of days between two dates8)Input : HashmapFind keys which are odd and calculate the sum of its corresponding value9)Input1:String (Rabbit)Input 2:'-'Insert the second char between each characters in the string after reversing output:t-i-b-b-i-R10)Average b/w largest and smallest element in an array of int11) input={1,2,13,15,20,30} input2=10; sum the element and reverse the result;output=87-------------------vijay1. STRING 1="---FALG----P-E"STRING 2="---LOBD----K-I"INDEX AND POSITION OF STRING 1 AND 2 "-" SHOULD BE SAME2. DIFF BETWEEN 2 DATES(D1 AND D2) O/P IN MONTHS3. LIST1={12,13,14,15,16};LIST2={2,3,4,5,6};CONDITION-INDEX-0---TAKE AS EVENO/P====EVEN INDEX OF LIST2,ODD INDEX OF LIST2EVEN INDEX OF LIST1eg:{2,13,4,15,6}4. STRING S="FLOWE.GIF"O/P SHOUD BE EXTENSION OF FILE(eg:GIF)----------------vijayan1. In an integer array, each element should be raised to the power ofthe index, and they should be added. the sum is the output.eg:input{1,2,3,4}output:1+2+9+64=762. validation of a time in hh:mm format...ignore case for am and pminput:"9:25 am"-valid"12:59 PM"-valid"13:45 am"-invalid3. sum of non prime numbers upto n4. Check if a string palindrome.Return 1 if the string is palindrome as well as it should have more than 1 unique vowels. else return -1Eg: nayan is a palidrome but only 1 unique vowel 'a' return -1Eg: naeyean return 15. input1=aaabbxxxcoutput1=2input1=abcdoutput1=-1 have to count the character coming 2 or more consecutive times..if true then return no of counts else -1 ----------------ram_anna1.input array={red,green,blue,ivory}sort the given arrayreverse the given arrayif user input is 1 it should give oth element of an reversed array.2.In a hash map get the average of all the values in a map and round of to two decimal values.eg:{1:2.2f,2:3.3f}output:5.753.input: String 1="sriram12345babu6"output:214.String a="a very fine day"output:A Very Fine Day5.First ArrayList:1 5 6 8 9Second ArrayList: 5 6 7 9output:5 5 7 8logic: iterate the first array list find odd index elements and keep it in a new Array list without changing its indexIterate the second array list find the even index elements and keep it in a new Array list without changing its index.----------Saranraj1. return sum od non prime number intput=9;out put=1+4+6+8+9=282.check for the exact date format like dd/MM/yyyy Input 1:12/06/2003 print--> 1 Input 2:12/6/2003 print-->-13.PAN CARD Validation4.String Array should contain oly numbers ! Input 1={"12","12.35","one"} output--->-1 Input 2={"12","12.35"} output---->15.Take the word with a ma length in the given sentance in that check for vowels if so count the no.of occurances ! Input 1="God is Great" Output =2 Input 1="God is Greeat" Output =3------------sam1.reverese the numbersi/p = 13223o/p = 322312.sum of Palindrome numbers between 2 limits (upper and lower), do not consider single digit as palindrome.If number is not palindrome return 0ip1- 11ip2 35o/p-(11+22+33)-663. No repetiton of characters i/p - hello worldo/p - helo wrd4.In Hashmap, if the key value is divisable by 4 ,delete the key and values and return a int value of the remaining countip1-{12,"hi"},{2,"world"}op - 15. for the given string display the middle 2 value, case satisfies only if string is of even lengthip - javaop av