Tuesday, November 10, 2009

Java Tasks

Some questions to ponder over,

  • Write a program to get the first two integers in a array which sums up to a given value. An integer array is given and a sum value is given. You have to find the first two numbers in the array which can add to give given sum value. Example: Given array is {10,34,56,80,1,36,93,62,23,90,21} and sum is 155. In this case, 93 and 62 will be the values adding upto 155.


  • Write a program to reverse a string without using string buffer and string builder. Example " my name is vinod " should be reversed to "ym eman si doniv"


  • Write a boolean isChild(String parent, String child) method in java, which returns true if a child string is in parent string in the same order else false.
    Example1- parent1 - LOCAL,
    child1 - LOL
    returns true

    paren1 - CHANGE,
    child1 - AEC
    returns false


  • No comments:

    Post a Comment