What Are Some Java Practice Problems?


Quick Answer

Basic Java programming practice problems include simple warmup tasks such as Boolean logic, "for and while" loops, arrays, strings, substrings and parsing. Practice problems allow users to input code and see the finished product. Coding samples cross-reference the practitioner's work with the website creator's design using Java.

Continue Reading
Related Videos

Full Answer

For example, simple Boolean statements have criteria set aside in parentheses and potential messages in curly braces. The lines "if (temperature > 100) {System.out.println("Dang, it's hot!")}" produce the message "Dang, it's hot" if the program inputs a temperature above 100 degrees Fahrenheit. The Boolean "test" is in parentheses, and Java determines if the value is true or false. The body of the code, in this case the printed statement, displays on the computer if the program ascertains the temperature fits the criteria. Otherwise, Java skips this code.

Loops generate repeated results that meet certain that the computer does not skip until the process is complete. The lines "while (count < 100) { // test: boolean test within (..) System.out.println("count:" + count); // body: statements within {..} count = count + 1;}" continue to count items less than 100 while printing the word "count" until the string stops. If the initial input value is "1," Java counts from 1 to 99 then moves onto the next process. Instead of writing 99 lines or more of code for this process, Java code lets programmers compose a much simpler line to count up to a certain number.

Learn more about Computer Programming

Related Questions