Subjects

Subjects

Companies

Introductory Computer Science Quiz 7 with Answers and Key

1

Share

Save



<h2 id="pleaseprintyourname">Please Print Your Name</h2>
<p>Computer</p>
<p>{</p>
<ol>
<li>Write one loop that will print the integers in t

Sign up

Sign up to get unlimited access to thousands of study materials. It's free!

Access to all documents

Join milions of students

Improve your grades

By signing up you accept Terms of Service and Privacy Policy


<h2 id="pleaseprintyourname">Please Print Your Name</h2>
<p>Computer</p>
<p>{</p>
<ol>
<li>Write one loop that will print the integers in t

Sign up

Sign up to get unlimited access to thousands of study materials. It's free!

Access to all documents

Join milions of students

Improve your grades

By signing up you accept Terms of Service and Privacy Policy


<h2 id="pleaseprintyourname">Please Print Your Name</h2>
<p>Computer</p>
<p>{</p>
<ol>
<li>Write one loop that will print the integers in t

Sign up

Sign up to get unlimited access to thousands of study materials. It's free!

Access to all documents

Join milions of students

Improve your grades

By signing up you accept Terms of Service and Privacy Policy

Please Print Your Name

Computer

{

  1. Write one loop that will print the integers in the following pattern. Print them vertically and do not include the commas. [5 points]
for (int i = 1; i <= 5; i++) {
    System.out.println(i);
    System.out.println(i * 2);
}

Variable temp is created

for(int i = 0; i < 3; i++) {
    // Loop content
}
  1. Hand trace the following loop and show every step. Show how the variables change as the loop executes. [5 points] Date:
for (int j = 0; j < 3; j++) {
    temp += 2;
}

Loop A, start. i=0. 143, true. Loop occurs.
Loop B start.
j=0. j≤3, true. loop occurs. Temp now equals 3. j++; j now equals 1.
j=1. j≤3, true. Loop occurs. Temp now equals 5. j++; j now equals 2.
J=2. j<3, true. Loop occurs. Temp now equals 7. j++; j now equals 3.
j=3. j!<3, loop doesn't occur. To go Bend. i now equals 1
Loop A, start again. i=2. 143, true. Loop occurs.
Loop B start. j=0. j<3, true. Loop occurs. Temp now equals. j++; j now equals 1.
j=1. j²3, true. Loop starts. Temp now equals 11. j++; j now equals 2.
j=2. j<3, true. Loop occurs. Temp now equals 13. j++; j now equals 3.
j=3₁ j!<3, loop doesn't occur. Togo Bend. i now equals 2
Loop A, start again. i=2 143, true. Loop occurs.
Loop B start. j=0. j≤3, true. Loop occurs. Temp now equals 15. j++; j now equals 1.
j=1. j<3, true. Loop occurs. Temp now equals 17. j++; j now equals 2.
j=2. j<3, true. Loop occurs. Temp now equals 19. j++; j now equals 3.
j=3₁ j!<3, loop doesn't occur. Togo Bend. i now equals 3. i≤3 is false, loop and take end.

  1. Suppose we are looking for all of the periods in an article. The article is a String variable type, and your job is to count the number of periods. Write the code to count the periods in the article below. Notice that the article is not yet placed there, and the placeholder is shown instead. This is because your algorithm does not depend on the article. [5 points]
String article = "<some article will be placed here>";
int periodCount = 0;
for (int i = 0; i <= article.length(); i++) {
    if (string.charAt(i) == ".") {
        periodCount++;
    }
}
System.out.print(periodCount + " periods in article.");
  1. What do the letters RAM stand for?

Random Access Memory

  1. What is an object in the Java programming language?

An instance of a class

  1. What is a method in the Java programming language?

A statement that performs a task

  1. What is the size of an integer in the Java programming language?

4 bytes, 32 bits

  1. What is the size of a boolean in the Java programming language?

1 bit (as in 0, false or 1, true)

Summary - Computer Science / Programming

  • Quiz 7 in Introductory Computer Science covers loops exercises and multiple-choice questions
  • Questions include printing patterns using Java for loops, hand tracing of loop execution, and counting occurrences of periods in a String
  • Quizzes also test general computer science knowledge such as defining RAM and object or method in the Java programming language
  • Students are expected to understand basic concepts like the size of integers and booleans in Java
  • The quiz consists of practical programming problems and theoretical knowledge, suitable for testing students' understanding of loops and Java concepts.

Frequently asked questions on the topic of Computer Science / Programming

Q: Write a loop that will print the integers 1 to 5 vertically, followed by their doubles, without using commas. [5 points]

A: The loop to achieve this pattern is: for (int i = 1; i <= 5; i++) { System.out.println(i); System.out.println(i * 2); }

Q: Hand trace the loop 'for (int j = 0; j < 3; j++) { temp += 2; }' and show how the variables change as the loop executes. [5 points]

A: The loop executes as follows: 1. temp = 2 2. temp = 4 3. temp = 6

Q: Write a code to count the number of periods in a String article in Java. [5 points]

A: The code to count the periods in the article is: String article = "<some article will be placed here>"; int periodCount = 0; for (int i = 0; i < article.length(); i++) { if (article.charAt(i) == ".") { periodCount++; } } System.out.print(periodCount + " periods in article.");

Q: What do the letters RAM stand for?

A: RAM stands for Random Access Memory.

Q: What is an object in the Java programming language?

A: An object in the Java programming language is an instance of a class.

Can't find what you're looking for? Explore other subjects.

Knowunity is the # 1 ranked education app in five European countries

Knowunity is the # 1 ranked education app in five European countries

Knowunity was a featured story by Apple and has consistently topped the app store charts within the education category in Germany, Italy, Poland, Switzerland and United Kingdom. Join Knowunity today and help millions of students around the world.

Ranked #1 Education App

Download in

Google Play

Download in

App Store

Still not sure? Look at what your fellow peers are saying...

iOS User

I love this app so much [...] I recommend Knowunity to everyone!!! I went from a C to an A with it :D

Stefan S, iOS User

The application is very simple and well designed. So far I have found what I was looking for :D

SuSSan, iOS User

Love this App ❤️, I use it basically all the time whenever I'm studying

intro to comp sci quiz 7

1

Share

Save


<h2 id="pleaseprintyourname">Please Print Your Name</h2>
<p>Computer</p>
<p>{</p>
<ol>
<li>Write one loop that will print the integers in t

<h2 id="pleaseprintyourname">Please Print Your Name</h2>
<p>Computer</p>
<p>{</p>
<ol>
<li>Write one loop that will print the integers in t

<h2 id="pleaseprintyourname">Please Print Your Name</h2>
<p>Computer</p>
<p>{</p>
<ol>
<li>Write one loop that will print the integers in t

a quiz on loops

Similar Content

Know Introduction to C++ Programming thumbnail

2

Introduction to C++ Programming

Learn the basics of C++ programming language with this simple and practical tutorial for beginners. Developed by Bjarne Stroustrup in 1979.

Know STEM: Electricity thumbnail

0

STEM: Electricity

Circuits, Vocabulary, and an expirement explanation.

Know Introduction to Computer Programming thumbnail

21

Introduction to Computer Programming

This study material contains information on the basics of Computer Programming. Several important terms are included, as well as examples.

Please Print Your Name

Computer

{

  1. Write one loop that will print the integers in the following pattern. Print them vertically and do not include the commas. [5 points]
for (int i = 1; i <= 5; i++) {
    System.out.println(i);
    System.out.println(i * 2);
}

Variable temp is created

for(int i = 0; i < 3; i++) {
    // Loop content
}
  1. Hand trace the following loop and show every step. Show how the variables change as the loop executes. [5 points] Date:
for (int j = 0; j < 3; j++) {
    temp += 2;
}

Loop A, start. i=0. 143, true. Loop occurs.
Loop B start.
j=0. j≤3, true. loop occurs. Temp now equals 3. j++; j now equals 1.
j=1. j≤3, true. Loop occurs. Temp now equals 5. j++; j now equals 2.
J=2. j<3, true. Loop occurs. Temp now equals 7. j++; j now equals 3.
j=3. j!<3, loop doesn't occur. To go Bend. i now equals 1
Loop A, start again. i=2. 143, true. Loop occurs.
Loop B start. j=0. j<3, true. Loop occurs. Temp now equals. j++; j now equals 1.
j=1. j²3, true. Loop starts. Temp now equals 11. j++; j now equals 2.
j=2. j<3, true. Loop occurs. Temp now equals 13. j++; j now equals 3.
j=3₁ j!<3, loop doesn't occur. Togo Bend. i now equals 2
Loop A, start again. i=2 143, true. Loop occurs.
Loop B start. j=0. j≤3, true. Loop occurs. Temp now equals 15. j++; j now equals 1.
j=1. j<3, true. Loop occurs. Temp now equals 17. j++; j now equals 2.
j=2. j<3, true. Loop occurs. Temp now equals 19. j++; j now equals 3.
j=3₁ j!<3, loop doesn't occur. Togo Bend. i now equals 3. i≤3 is false, loop and take end.

  1. Suppose we are looking for all of the periods in an article. The article is a String variable type, and your job is to count the number of periods. Write the code to count the periods in the article below. Notice that the article is not yet placed there, and the placeholder is shown instead. This is because your algorithm does not depend on the article. [5 points]
String article = "<some article will be placed here>";
int periodCount = 0;
for (int i = 0; i <= article.length(); i++) {
    if (string.charAt(i) == ".") {
        periodCount++;
    }
}
System.out.print(periodCount + " periods in article.");
  1. What do the letters RAM stand for?

Random Access Memory

  1. What is an object in the Java programming language?

An instance of a class

  1. What is a method in the Java programming language?

A statement that performs a task

  1. What is the size of an integer in the Java programming language?

4 bytes, 32 bits

  1. What is the size of a boolean in the Java programming language?

1 bit (as in 0, false or 1, true)

Summary - Computer Science / Programming

  • Quiz 7 in Introductory Computer Science covers loops exercises and multiple-choice questions
  • Questions include printing patterns using Java for loops, hand tracing of loop execution, and counting occurrences of periods in a String
  • Quizzes also test general computer science knowledge such as defining RAM and object or method in the Java programming language
  • Students are expected to understand basic concepts like the size of integers and booleans in Java
  • The quiz consists of practical programming problems and theoretical knowledge, suitable for testing students' understanding of loops and Java concepts.

Frequently asked questions on the topic of Computer Science / Programming

Q: Write a loop that will print the integers 1 to 5 vertically, followed by their doubles, without using commas. [5 points]

A: The loop to achieve this pattern is: for (int i = 1; i <= 5; i++) { System.out.println(i); System.out.println(i * 2); }

Q: Hand trace the loop 'for (int j = 0; j < 3; j++) { temp += 2; }' and show how the variables change as the loop executes. [5 points]

A: The loop executes as follows: 1. temp = 2 2. temp = 4 3. temp = 6

Q: Write a code to count the number of periods in a String article in Java. [5 points]

A: The code to count the periods in the article is: String article = "<some article will be placed here>"; int periodCount = 0; for (int i = 0; i < article.length(); i++) { if (article.charAt(i) == ".") { periodCount++; } } System.out.print(periodCount + " periods in article.");

Q: What do the letters RAM stand for?

A: RAM stands for Random Access Memory.

Q: What is an object in the Java programming language?

A: An object in the Java programming language is an instance of a class.

Can't find what you're looking for? Explore other subjects.

Knowunity is the # 1 ranked education app in five European countries

Knowunity is the # 1 ranked education app in five European countries

Knowunity was a featured story by Apple and has consistently topped the app store charts within the education category in Germany, Italy, Poland, Switzerland and United Kingdom. Join Knowunity today and help millions of students around the world.

Ranked #1 Education App

Download in

Google Play

Download in

App Store

Still not sure? Look at what your fellow peers are saying...

iOS User

I love this app so much [...] I recommend Knowunity to everyone!!! I went from a C to an A with it :D

Stefan S, iOS User

The application is very simple and well designed. So far I have found what I was looking for :D

SuSSan, iOS User

Love this App ❤️, I use it basically all the time whenever I'm studying