Question

In: Computer Science

Q1: Which of the following is not an algorithm? A recipe. Operating instructions. Textbook index. Shampoo...

Q1: Which of the following is not an algorithm?

  1. A recipe.
  2. Operating instructions.
  3. Textbook index.
  4. Shampoo instructions (lather, rinse, repeat).

Q2: Which of the following is true?

  1. Pseudocode is used to describe an algorithm.
  2. Pseudocode is translatable by the programmer into a programming language (like Java).
  3. Pseudocode is used to describe executable statements that will eventually be translated by the programmer into a program.
  4. All of the above.

Q3: Which of the following is not a benefit of “goto-less programming”?

  1. Easier to debug and modify
  2. Shorter
  3. Clearer
  4. More likely to be bug free

Q4: Which of the following is not a control structure:

  1. Sequence structure.
  2. Selection structure.
  3. Repetition structure.
  4. Action structure.

Q5: Which of the following is an action-state symbol?

  1. diamonds.
  2. circles.
  3. rectangles with left and right sides replaced with arcs curving outward.
  4. rounded rectangles.

Q6: Which statement is false?

  1. Unless directed otherwise, the computer executes Java statements one after the other in the order in which they are written.
  2. Activity diagrams normally show the Java code that implements the activity.
  3. Like pseudocode, activity diagrams help programmers develop and represent algorithms.
  4. The arrows in the activity diagram represent transitions, which indicate the order in which the actions represented by the action states occur.

Q7: Which of the following is a double-selection control statement?

  1. do…while.
  2. for.
  3. if…else.
  4. if.

Q8: Which of the following is not a Java keyword?

  1. do
  2. next
  3. while
  4. for

Q9: What is output by the following Java code segment?

int temp;

temp = 200;

if ( temp > 90 )

   System.out.println( "This porridge is too hot." );

if ( temp < 70 )

   System.out.println( "This porridge is too cold." );

if ( temp == 80 )

   System.out.println( "This porridge is just right!" );

  1. This porridge is too hot.    
  2. This porridge is too cold.
  3. This porridge is just right!
  4. None of the above.

                                            

Q10: A decision symbol in an activity diagram takes the shape of a ________.

  1. Diamond.
  2. Rectangle.
  3. Circle.
  4. Question Mark.

Q11: Which of the following is not included in an activity diagram for a control structure?

  1. Transition arrows
  2. Attribute
  3. Action state
  4. Decision symbols

Q12: Which of the following is not true about the conditional operator ( ?: )?

  1. The conditional operator is a ternary operator, meaning that it takes three operands.
  2. The first operand is a boolean expression.
  3. The second operand is the result value if the condition evaluates to false.
  4. The second operand is the result value if the condition evaluates to true.

Q13: What is output by the following Java code segment?

int temp;

temp = 180;

if ( temp > 90 )

{

   System.out.println( "This porridge is too hot." );

  

   // cool down

   temp = temp – ( temp > 150 ? 100 : 20 );

} // end if

else

{

   if ( temp < 70 )

   {

      System.out.println("This porridge is too cold.");

           

      // warm up

      temp = temp + (temp < 50 ? 30 : 20);

   } // end if

} // end else

if ( temp == 80 )

   System.out.println( "This porridge is just right!" );

  1. This porridge is too hot.
  2. This porridge is too cold.
    This porridge is just right!
  3. This porridge is just right!
  4. None of the above.

Q14: A dangling-else can be clarified by using:

  1. Indentation
  2. Parentheses ()
  3. Braces {}
  4. End-of-line comment //

Q15: The empty statement is denoted with what symbol?

  1. Semicolon ;
  2. Parentheses ()
  3. Braces {}
  4. End-of-line comment //

ANS: a. Semicolon ;

Q16: Which statement is false?

  1. Both syntax errors and logic errors are caught by the compiler.
  2. Both syntax errors and logic errors have effects at execution time.
  3. Syntax errors are caught by the compiler. Logic errors have effects at execution time.
  4. Logic errors are caught by the compiler. Syntax errors have effects at execution time.

Q17: What is output by the following Java code segment?

int temp;

temp = 180;

while ( temp != 80 )

{

   if ( temp > 90 )

   {

      System.out.print( "This porridge is too hot! " );

      // cool down

      temp = temp – ( temp > 150 ? 100 : 20 );

   } // end if

   else

   {

      if ( temp < 70 )

      {

         System.out.print(

            "This porridge is too cold! ");

           

            // warm up

            temp = temp + (temp < 50 ? 30 : 20);

      } // end if

   } // end else

} // end while

if ( temp == 80 )

      System.out.println( "This porridge is just right!" );

  1. This porridge is too cold! This porridge is just right!
  2. This porridge is too hot! This porridge is just right!
  3. This porridge is just right!
  4. None of the above.

Q18: Which of the following is not an error (either a syntax error or a logic error)?

  1. Neglecting to include an action in the body of a while statement that will eventually cause the condition to become false.
  2. Spelling a key word (such as while or if) with a capitalized first letter.
  3. Using a condition for a while statement that is initially false.
  4. An infinite loop.

Q19: In an activity diagram, the merge symbol has the same shape as what other symbol?

  1. Decision symbol
  2. Action symbol
  3. Transition arrows
  4. Initial state

Solutions

Expert Solution

Q1)

c. Textook index

It has table of contents. it doesnt say abot any actions

Q2)

c)Pseudocode is used to describe executable statements that will eventually be translated by the programmer into a program.

Q3)

b Shorter

Q4)

d. Action Structure

Q5)

c)rectangles with left and right sides replaced with arcs curving outward.

Q6)

b)Activity diagrams normally show the Java code that implements the activity.

Q7)

if…else.

Q8)

b) next

Q9)

a) This porridge is too hot.

Q10)

a. Diamond.

Q11)

b) Attribute

Q12)

c. The second operand is the result value if the condition evaluates to false.

Q13)

d.None of the above.

Q14)

c. Braces {}

Q15)

a. Semicolon ;

Q16)

c. Syntax errors arecaught by the compiler. Logic errors have effects at execution time. d. Logic errors are caught by the

Q17)

b. This porridge is too hot! This porridge is just right!

Q18)
c. Using a condition for a while structure that is initially false

Q19)

a. Decision symbol


Related Solutions

Develop an Algorithm and java program using Design Recipe for the following problems. Draw a flowchart...
Develop an Algorithm and java program using Design Recipe for the following problems. Draw a flowchart to compute the largest and smallest of 4 numbers : Write a Java Program for the above flowchart, use methods(functions), and nested if-else statements. Take input from the user using the Scanner object. Use separate methods to compute the Largest and Smallest of the numbers. Method 1 Name: findLargest(param 1, param 2, param 3, param 4) Method 2 Name: findSmallest(param 1, param 2, param...
Q1. Write an algorithm to do the following operation on an array passed as parameter: If...
Q1. Write an algorithm to do the following operation on an array passed as parameter: If an element of the array is having more than one occurrence, then keep the first occurrence and remove all other occurrences of the element.
Define Instructions: After reading Chapter 4 of the textbook, define the following terms: -System of linear...
Define Instructions: After reading Chapter 4 of the textbook, define the following terms: -System of linear equations -Solution to a system of equations -Consistent system of equations -Inconsistent system of equations Write a good paragraph with at least 5 sentences using a minimum of 75 words.
Q1 Which of the following are NOT tests which are used to assess the performance of...
Q1 Which of the following are NOT tests which are used to assess the performance of astabilization or solidification process? a. corrosion test b. EP TOX c. paint filter test d. TCLP Q2 Given that you receive a dose of radiation of 1 milli-rad, the highest tissue damage wouldresult if the radiation adsorbed was in the form of: a. Alpha b. Beta c. Gamma d. X-rays e. all the same Q3 When a radioactive isotope decays by emission of an...
which of the following is TRUE about index mutual funds? a. index funds are more actively...
which of the following is TRUE about index mutual funds? a. index funds are more actively managed than etfs b. index funds have lower expenses than hedge funds. c. hedge funds are usually index funds d. index funds tend to be more risky than actively-managed funds. e. index funds are less regulated than hedge funds.
14. According to the textbook, which of the following statements is (are) correct? (x) In the...
14. According to the textbook, which of the following statements is (are) correct? (x) In the open economy macroeconomic model of the U.S. economy, net capital outflow is equal to the quantity of U.S. dollars supplied in the foreign exchange market. (y) In the market for foreign currency exchange, the amount of U.S. net capital outflow desired at each real interest rate represents the quantity of U.S. dollars supplied for the purpose of buying foreign assets. (z) In the market...
Which of the following is the definition of the PCE IndexPCE Index ? A. Upper A...
Which of the following is the definition of the PCE IndexPCE Index ? A. Upper A weighted average of of prices of a market basket of goods and services purchased by typical urban consumersA weighted average of of prices of a market basket of goods and services purchased by typical urban consumers. B. Upper A broad price index measuring the changes in prices of all new goods and services producedA broad price index measuring the changes in prices of all...
Q1: Consider the following scenario. A company operating in the airline sector has been experiencing a...
Q1: Consider the following scenario. A company operating in the airline sector has been experiencing a brand crisis following a video posted in social media showing rude behavior of staff. A brand crisis has significant impact on customers’ intention to buy from the brand, or to recommend it to family/friends. Propose a qualitative research strategy to assess the impact of this brand crisis on the company’s revenue. Ensure to detail and motivate your recommended strategy including potential limitations of qualitative...
The following relates to the Lerner Index. Which of the following statements is (are) true? I....
The following relates to the Lerner Index. Which of the following statements is (are) true? I. Firms have less power to take advantage of consumers in a market when consumers are very price sensitive. II. If P = $100 and MC = $60, the Lerner index = 0.40. III. If the price elasticity of demand is -2.0, the Lerner index is 0.50. IV. A monopolist has more mark-up power if | Ed| =0.25 rather than if | Ed| =10
The following relates to the Lerner Index. Which of the following statements is (are) true? I....
The following relates to the Lerner Index. Which of the following statements is (are) true? I. Firms have less power to take advantage of consumers in a market when consumers are very price sensitive. II. If P = $100 and MC = $60, the Lerner index = 0.40. III. If the price elasticity of demand is -2.0, the Lerner index is 0.50. IV. A monopolist has more mark-up power if | Ed| =0.25 rather than if | Ed| =10 A....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT