

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Computer Programming Chp6 Critical Thinking Test Q&A 2026.
Typology: Exams
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Compare and Contrast counters and accumulators. List two uses of each? - ANSA counter is a variable that increments by a fixed value for example x+= 1, would add 1 to x everyone time the loop is run, whereas an accumulator is a variable that increments by varying amount, say x += y, in this case it would change by varying amount each time y is changed. Yet they both serve as counting variables. Computer Programming Chp6 Critical Thinking Questions - ANS Explain the difference between a while statement and a do-while statement? - ANSA while statement first assesses the condition then compile the commands, whereas the do-while statement runs the commands once then assesses the condition. True or False: A counter is incremented by a constant amount. - ANSTrue True or False: A while statement iterates once before evaluating the condition. - ANSFalse, a do- while statement iterates once before evaluating the condition. True or False: An accumulator signifies that a loop should stop iterating. - ANSFalse, a Sentinel value indicates that a loop should stop iterating. True or False: Sentinel values must always be the value -1. - ANSFalse, Sentinel values can be set to anything. True or False: String variables are primitive data types. - ANSFalse, string variable is not a primitive data type. True or False: Strings are compared using relational operators such as >. - ANSFalse, the strings are compared using compareTo() method True or False: The first character of a string has a index position 1. - ANSFalse, the first character of a string has a index position 0.
True or False: The string class includes a method for determining the location of a substring within a string. - ANSTrue True or False: A variable declared in a for statement can be used again anywhere in the program code. - ANSFalse, the variable declared in a for loop cannot be used anywhere outside of the loop. What is an infinite loop? - ANSAn infinite loop is when a loop goes on forever. What is meant by overflow? - ANSAn overflow is when a condition that occurs when a number is too large to be stored in a specified number of bits. What is the purpose of a loop structure? - ANSA loop structure that repeats a set of commands based on the condition.