technology and zen of life

β€œA heisenbug (named after the Heisenberg Uncertainty Principle) is a computer bug that disappears or alters its characteristics when an attempt is made to study it.”

Test your Java programming Skills!

There a nice little site which allows you to test and refresh your Java Programming skills by giving you a series of challenges to solve. I found it quite interesting. Although it’s does not completely covers all the aspects of java programming (e.g. the OOP concepts) but normal coding concepts which involves using control statements, arrays, string processing etc. are nicely covered.

Here is the link-

(I tried to solve each one of them with a single line of code and was successful for most of the easier problems. Try out and see if it is possible for you.) Leave a comment if help is needed.

Leave a Reply

50 Responses

  1. Dheeraj says:

    Thanks Buddy..

  2. Md. majedur rahaman says:

    I am very interest to learn java programing language

  3. Chris says:

    public String everyNth(String str, int n) {
    String nstr = new String();
    if (str != “”){
    int len = str.length();
    int x = 0;

    while (x < len){
    nstr += str.charAt(x);
    x += n;
    return nstr;

  4. […] threads in java 451 CAOS Theory » Java mutiny in the making Guessing Game – Java Forums Test your Java programming Skills! | TechMonks Crash Course: […]

  5. faithict says:


    I just started on the first class of java here in this website and i am already having trouble with it. I took Java class like 3 years ago and now i am thinking of brushing up my java skills. This is what i did for the first question of the website on determine if it is a holiday. I am not sure where i had gone wrong in my code as i am getting compilation error. Any advice is greatly appreciate by me. Thank you!

    public boolean sleepIn(boolean weekday, boolean vacation) {
    if(weekday==false && vacation==false)
    boolean test = true;
    return test;
    if(weekday==true && vacation==false)
    boolean test=false;
    return test;
    if(weekday==false && vacation==true)
    boolean test = true;
    return test;

    • Yoshi says:

      faithict try this…

      the ! means not

      public boolean sleepIn(boolean weekday, boolean vacation) {
      if (!weekday || vacation){
      return true;
      else {
      return false;


  6. Simba says:

    this is test πŸ˜›
    do use ‘& lt ;’ (without qoutes and spaces) for less than symabol in your code

  7. Simba says:

    this is test πŸ˜›
    put all ur code in between <code><\code> tag

  8. AnilKishore says:

    lol πŸ˜€ ….. sorry once again …
    Can any1 help me :( .. Is thr any syntax to follow to get
    the code posted here ..??

  9. AnilKishore says:

    sorry.. i couldn’t get the right characters printed here :(
    ((goal – 5*big ) = 0).. should b replaced with ..
    ” ( ( ( goal – 5 * big ) = 0 )

  10. AnilKishore says:

    Mine is….
    return (big >= 0) ? (((goal – 5*big ) = 0) ? true : (makeBricks(small,big-1,goal))) : (false);
    Ur’s is better :)

  11. Simba says:

    non-Recursive solution

    return goal/5 <= big ? goal%5<=small : (goal-5*big)<=small;

  12. Simba says:

    nice problem

    public boolean makeBricks(int small, int big, int goal) {
    return small >= goal ? true : ( (big > 0 && goal >=5) ? makeBricks(small, big-1, goal-5):false);

    Whats ur solution

  13. AnilKishore says:

    Hi !! I just got this ( ) in a single line :)
    Who else got it ??

  14. Fr0z3n says:

    yes we can. like this. Try others from the arrays as they are almost same.
    return new int[]{nums[0], nums[nums.length-1]};

  15. AnilKishore says:

    ya… sorry .. a bit over confident :(
    Can we create arrays in return statement?? Then how to solve this??
    [link] [/link]

  16. Fr0z3n says:

    consider when t1 = 90 && t2 = -2. Your solution will return me true which is wrong. You may have passed the test cases on the site, but the solution is wrong.

  17. Anil Kishore says:

    OOPS!!! I could get the characters printed :(
    here it goes

    return (t1*t2 lessthan -101);

  18. Anil Kishore says:

    β€œGiven two temperaturessay t1,t2, return true if one is less than 0 and the other is greater than 100.”
    Froz3n replied
    return (t1 100) || (t2 100)”
    I got a still better solution..(i guess) ..

    return (t1*t2

  19. Rohit says:

    Yeah .. this is a good site… I ‘ll definitely spend time a brush up my programming skills by solving some gud 1s specially the recursion 1s…….

  20. Fr0z3n says:

    try solving some harder ones in one line. These are easier to solve. The harder one will require use of recursion as the one (everyNth) posted by me.

  21. Fr0z3n says:

    I used this:
    return (str.length() - str.replace("e","").length() >= 1 &&
    str.length() - str.replace("e","").length() <= 3);

  22. Simba says:

    try this
    return (str.length() - str.replaceAll("e","").length() >= 1 &&
    str.length() - str.replaceAll("e","").length() <= 3);

  23. Fr0z3n says:

    Thats the point. No need of replacing ‘e’ with a space. Just replace with a blank character ”.

  24. Simba says:

    i checked this out that logic wont work cox of trim() method removes leading and trailing spaces not spaces in between the string.
    Nice try (Y)

  25. Fr0z3n says:

    that character is the problem due to posting here and not actually written by him.

  26. Simba says:

    @ Rohit

    You are using wrong key expressing character (`) instead of (‘)
    check your code again

  27. Fr0z3n says:

    Found it now.
    It is working for me.
    Please check that you are writing everything correctly. (Note: you should replace ‘e’ with a blank character ” and not a space ‘ ‘)
    Also you don’t need to use trim() i guess.

  28. Fr0z3n says:

    which problem. i dont find any stringE problem. please give the link. And for less than type “& lt ;” without spaces and quotes.

  29. Rohit says:

    [less than equal to] 3 ) ? true : false;

  30. Rohit says:

    jst add the followin code to wht I hve pasted at 5:51 am

  31. Rohit says:

    lo ab yeh code kyon nahi paste ho raha !!! :(

  32. Rohit says:

    return (str.length() – ((str.replace(‘e’,’ ‘)).trim()).length() >= 1) && (str.length() – ((str.replace(‘e’,’ ‘)).trim()).length()

  33. Rohit says:

    HELP ME OUT !!!

    y s ths code nt wrkin for the stringE problem…??

    return (str.length() – ((str.replace(‘e’,’ ‘)).trim()).length() >= 1) && (str.length() – ((str.replace(‘e’,’ ‘)).trim()).length()

  34. Rohit says:

    Yeah !!

    My code wrkin too….. nice problem…. took sum time [:(]

    i had the same sol as Fr0z3n [:)]

  35. Fr0z3n says:


    return (t1 < 0 && t2 > 100) || (t2 < 0 && t1 > 100)

  36. Anil Kishore says:

    Very nice solution.. didn’t think of recursion ..:(
    How did u do this in 1line? I got it :)
    “Given two temperaturessay t1,t2, return true if one is less than 0 and the other is greater than 100.”

  37. Simba says:

    return str.length() <= n ? str.substring(0,1):str.substring(0,1) + everyNth(str.substring(n),n);

  38. Simba says:

    this is similar as top just remove str.substring(0,1) out and make it str.charAt(0). We used skew conditions and so are the statements.

  39. Simba says:

    return str.length() <= n ? str.substring(0,1):str.substring(0,1) + everyNth(str.substring(n),n);

  40. Fr0z3n says:

    Ok. let me try posting the code.

    return str.charAt(0) + (str.length() > n : everyNth(str.substring(n), n) : "");

  41. Simba says:

    this is not the answer i am unable to post it correctly coz of lack of my understanding in using tags provided by wordpress :S

  42. Fr0z3n says:

    how is that giving you the correct answer. :S

  43. Simba says:

    Yea nice problem: took time but finally able to solve it
    Here is solution:
    return str.length()

  44. Amit says:

    JFace is also a good Frame Work to work with JSPs and servlets.
    Raghav is doing btp – building web application in Spring Framework

  45. Fr0z3n says:

    No but i will look into it.
    Have you heard of OpenLaszlo.

  46. Sujit says:

    btw did u try Spring Framework ?

    its very nice to make web based application..

Email Subscription


The views expressed on this blog are personal. We do not claim to be a representative voice of the views of any organisation whatsoever. We are not responsible for the content present on the blogs to which we have linked.Views expressed are solely that of the author and does not reflect a collective opinion of contributors.
%d bloggers like this: