Apr 9, 2007 -- posted by TechMonk
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- http://javabat.com/
(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.

Thanks!!
Thanks Buddy..
I am very interest to learn java programing language
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;
}
it returns a string consist of every Nth character from original string str..
[...] threads in java 451 CAOS Theory » Java mutiny in the making Guessing Game – Java Forums Test your Java programming Skills! | TechMonks eonheatingandcooling.com/2010/11/29/oil-reaches-two-week-high-on-ireland-rescue/ Crash Course: [...]
Hello,
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;
}
}
faithict try this…
the ! means not
public boolean sleepIn(boolean weekday, boolean vacation) {
if (!weekday || vacation){
return true;
}
else {
return false;
}
}
this is test
do use ‘& lt ;’ (without qoutes and spaces) for less than symabol in your code
this is test
put all ur code in between <code><\code> tag
lol
….. sorry once again …
.. Is thr any syntax to follow to get
Can any1 help me
the code posted here ..??
sorry.. i couldn’t get the right characters printed here
((goal – 5*big ) = 0).. should b replaced with ..
” ( ( ( goal – 5 * big ) = 0 )
Mine is….
return (big >= 0) ? (((goal – 5*big ) = 0) ? true : (makeBricks(small,big-1,goal))) : (false);
.
.
Ur’s is better
non-Recursive solution
return goal/5 <= big ? goal%5<=small : (goal-5*big)<=small;
nice problem
solution:
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
Hi !! I just got this ( http://javabat.com/prob?id=Logic.makeBricks ) in a single line
Who else got it ??
yes we can. like this. Try others from the arrays as they are almost same.
return new int[]{nums[0], nums[nums.length-1]};
ya… sorry .. a bit over confident
.
Can we create arrays in return statement?? Then how to solve this??
[link] http://javabat.com/prob?id=Array1.makeEnds [/link]
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.
OOPS!!! I could get the characters printed
here it goes
return (t1*t2 lessthan -101);
“Given two temperaturessay t1,t2, return true if one is less than 0 and the other is greater than 100.”
.
Froz3n replied
“simple
return (t1 100) || (t2 100)”
.
I got a still better solution..(i guess) ..
return (t1*t2
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…….
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.
I used this:
return (str.length() - str.replace("e","").length() >= 1 &&str.length() - str.replace("e","").length() <= 3);
try this
return (str.length() - str.replaceAll("e","").length() >= 1 &&str.length() - str.replaceAll("e","").length() <= 3);
Thats the point. No need of replacing ‘e’ with a space. Just replace with a blank character ”.
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)
that character is the problem due to posting here and not actually written by him.
@ Rohit
You are using wrong key expressing character (`) instead of (‘)
check your code again
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.
which problem. i dont find any stringE problem. please give the link. And for less than type “& lt ;” without spaces and quotes.
[less than equal to] 3 ) ? true : false;
jst add the followin code to wht I hve pasted at 5:51 am
lo ab yeh code kyon nahi paste ho raha !!!
return (str.length() – ((str.replace(‘e’,’ ‘)).trim()).length() >= 1) && (str.length() – ((str.replace(‘e’,’ ‘)).trim()).length()
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()
Yeah !!
My code wrkin too….. nice problem…. took sum time [:(]
i had the same sol as Fr0z3n [:)]
simple
return (t1 < 0 && t2 > 100) || (t2 < 0 && t1 > 100)
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.”
return str.length() <= n ? str.substring(0,1):str.substring(0,1) + everyNth(str.substring(n),n);
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.
return str.length() <= n ? str.substring(0,1):str.substring(0,1) + everyNth(str.substring(n),n);
Ok. let me try posting the code.
return str.charAt(0) + (str.length() > n : everyNth(str.substring(n), n) : "");
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
how is that giving you the correct answer. :S
Yea nice problem: took time but finally able to solve it
Here is solution:
return str.length()Try solving http://javabat.com/prob?id=Warmup.everyNth in one line.
JFace is also a good Frame Work to work with JSPs and servlets.
Raghav is doing btp – building web application in Spring Framework
No but i will look into it.
Have you heard of OpenLaszlo.
btw did u try Spring Framework ?
its very nice to make web based application..