Java Code Final Test Q&A 100% VERIFIED AND PASSED
Java Code Final Test Q&A 100% VERIFIED AND PASSED Given an int variable k that has already been declared , use a do...while loop to print a single line consisting of 53 asterisks. Use no variables other than k. - ANSWER k = 1; do { S("*"); k++; } while (k = 53); Given an int variable n that has already been declared and initialized to a positive value , use a while loop to print a single line consisting of n asterisks. Use no variables other than n. - ANSWER while ( n 0) { S("*"); n--; } Given an int variable k that has already been declared , use a while loop to print a single line consisting of 88 asterisks. Use no variables other than k. - ANSWER k = 1; while ( k = 88 ) { S("*"); k++; } Consider this code: "int s = 20; int t = s++ + --s;". What are the values of s and t? - ANSWER s is 20 and t is 40 Consider this code: "int v = 20; --v; Sln(v++);". What value is printed, what value is v left with? - ANSWER 19 is printed, v ends up with 20 Given an integer variable timer, write a statement that uses the auto-decrement operator to decrease the value of that variable by 1. - ANSWER timer--; Given an integer variable strawsOnCamel, write a statement that uses the autoincrement operator to increase the value of that variable by 1. - ANSWER strawsOnCamel++; Given an int variable n that has already been declared and initialized to a positive value , use a do...while loop to print a single line consisting of n asterisks. Use no variables other than n. - ANSWER do { S("*"); n--; } while (n 0); Given an int variable k that has already been declared , use a for loop to print a single line consisting of 97 asterisks. Use no variables other than k. - ANSWER for(k = 0; k97; k++) { S("*");
Información del documento
- Subido en
- 18 de septiembre de 2023
- Número de páginas
- 8
- Escrito en
- 2023/2024
- Tipo
- Examen
- Contiene
- Preguntas y respuestas