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.
btw did u try Spring Framework ?
its very nice to make web based application..
No but i will look into it.
Have you heard of OpenLaszlo.
JFace is also a good Frame Work to work with JSPs and servlets.
Raghav is doing btp – building web application in Spring Framework
Try solving http://javabat.com/prob?id=Warmup.everyNth in one line.
Yea nice problem: took time but finally able to solve it
Here is solution:
return str.length()
how is that giving you the correct answer. :S
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
Ok. let me try posting the code.
return str.charAt(0) + (str.length() > n : everyNth(str.substring(n), n) : "");
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);
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.”
simple
return (t1 < 0 && t2 > 100) || (t2 < 0 && t1 > 100)
Yeah !!
My code wrkin too….. nice problem…. took sum time [:(]
i had the same sol as Fr0z3n [:)]
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()
return (str.length() – ((str.replace(‘e’,’ ‘)).trim()).length() >= 1) && (str.length() – ((str.replace(‘e’,’ ‘)).trim()).length()
lo ab yeh code kyon nahi paste ho raha !!! π¦
jst add the followin code to wht I hve pasted at 5:51 am
[less than equal to] 3 ) ? true : false;
which problem. i dont find any stringE problem. please give the link. And for less than type “& lt ;” without spaces and quotes.
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.
@ Rohit
You are using wrong key expressing character (`) instead of (‘)
check your code again
that character is the problem due to posting here and not actually written by him.
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)
Thats the point. No need of replacing ‘e’ with a space. Just replace with a blank character ”.
try this
return (str.length() - str.replaceAll("e","").length() >= 1 &&
str.length() - str.replaceAll("e","").length() <= 3);
I used this:
return (str.length() - str.replace("e","").length() >= 1 &&
str.length() - str.replace("e","").length() <= 3);
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.
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…….
β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
OOPS!!! I could get the characters printed π¦
here it goes
return (t1*t2 lessthan -101);
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.
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]
yes we can. like this. Try others from the arrays as they are almost same.
return new int[]{nums[0], nums[nums.length-1]};
Hi !! I just got this ( http://javabat.com/prob?id=Logic.makeBricks ) in a single line π
Who else got it ??
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
non-Recursive solution
return goal/5 <= big ? goal%5<=small : (goal-5*big)<=small;
Mine is….
return (big >= 0) ? (((goal – 5*big ) = 0) ? true : (makeBricks(small,big-1,goal))) : (false);
.
.
Ur’s is better π
sorry.. i couldn’t get the right characters printed here π¦
((goal – 5*big ) = 0).. should b replaced with ..
” ( ( ( goal – 5 * big ) = 0 )
lol π ….. sorry once again …
Can any1 help me π¦ .. Is thr any syntax to follow to get
the code posted here ..??
this is test π
put all ur code in between <code><\code> tag
this is test π
do use ‘& lt ;’ (without qoutes and spaces) for less than symabol in your code
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;
}
}