Intro To Cs Second Quarterly

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By KretschK
K
KretschK
Community Contributor
Quizzes Created: 9 | Total Attempts: 6,743
Questions: 12 | Attempts: 214

SettingsSettingsSettings
Intro To Cs Second Quarterly - Quiz

Questions and Answers
  • 1. 

    Consider a form that has a text box called txtName, a check box called chkMale, a button, and a label called lblAddr. Assume text box also contains the first and last name of a person. Write the code for the button that does the following. Writes into the label the first initial  followed by the last name. If the check box is checked, the name displayed in the label is preceded by "Mr.", otherwise it is preceded by "Ms."  For example, if the check box is checked, and the text box contains "Pete Seeger", the label should contain "Mr. P Seeger". If the check box is not checked and the text box contains "Joan Baez", the label should contain "Ms. J Baez".

  • 2. 

    Consider the String variable strSchool which equals "Middletown South". What is the difference between the expression strSchool.substring(3,6) and strSchool.remove(3, 6)?

  • 3. 

    Consider three variables intAmount, dblCost, and dblShipping, which contain the number of items purchased, the cost of each item, and the shipping charge. Write the code that calculates the total cost of the order. Keep in mind that if the cost of each item is over 100 dollars or the customer orders at least 10 items, shipping is free.

  • 4. 

    I'm writing a password generator. Among the changes I will make to the input string is to change all instances of the letter 'o' to the digit zero. Which String function would I use?

    • A.

      Substring

    • B.

      Pad

    • C.

      Replace

    • D.

      Insert

    Correct Answer
    C. Replace
    Explanation
    The correct answer is "replace". The replace function is used to replace all occurrences of a specified character or substring in a string with another character or substring. In this case, the letter 'o' needs to be replaced with the digit zero, so the replace function would be the appropriate choice to achieve this change in the input string.

    Rate this question:

  • 5. 

    I want my if statement to be true it my variable intAge is between 18 and 65, inclusive. Does the following if statement work? If 18 <= intAge OR intAge <= 65Then

    • A.

      Yes

    • B.

      No

    Correct Answer
    B. No
    Explanation
    Should be AND, not OR

    Rate this question:

  • 6. 

    Consider the following code Dim guitar as String = "Bruce Springsteen" What is returned from the following statement: guitar.StartsWith("bu")

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    Remember, character comparisons are case sensitive

    Rate this question:

  • 7. 

    What does the the following line of code do? Dim bar as String = "United States" Dim foo as String = bar.substring(bar.length() - 1, 1)

    • A.

      Crashes

    • B.

      Copies the last character in United States into the variable foo

    • C.

      Copies the first character in United States into the variable foo

    • D.

      Its a syntax error

    • E.

      Baraksan

    Correct Answer
    B. Copies the last character in United States into the variable foo
    Explanation
    The given line of code copies the last character in the string "United States" into the variable foo.

    Rate this question:

  • 8. 

    Are the following if statements equivalent (Do they produce true and false under the same conditions?) 1) If intTemp > 98.6 Then ... 2) If Not Temp <= 98.6 Then ...

    • A.

      Yes

    • B.

      No

    Correct Answer
    A. Yes
    Explanation
    The given if statements are equivalent because they both check if the value of "intTemp" is greater than 98.6. In the first statement, it directly compares "intTemp" with 98.6 using the greater than operator. In the second statement, it checks if "Temp" is not less than or equal to 98.6, which is equivalent to checking if "Temp" is greater than 98.6. Therefore, both statements will produce true and false under the same conditions.

    Rate this question:

  • 9. 

    Consider the following subroutine Public Sub MakeLabel(ByVal toggle as Boolean, ByVal Name as String,  ByVal n as Integer)         Dim strF as String = name.substring(0, n);         Dim strB as String = name.remove(0, n);         if toggle then            lblOutput.txt = strF.upper() & strB.ToLower()        else             lblOutput.text = strfF.lower() & strB.ToUpper()       endIf End Sub If I run the following statement MakeLabel(True, "January", 4) What is written in the lblOutput label?

    Correct Answer
    JANUary
    Explanation
    The given subroutine takes in three parameters: a boolean toggle, a string name, and an integer n. It first creates two new strings: strF, which is a substring of name from index 0 to n, and strB, which is the remaining portion of name after removing the first n characters.

    If the toggle is true, it sets the text of lblOutput to the concatenation of strF in uppercase and strB in lowercase. In this case, since the toggle is true and the name is "January", the resulting text in lblOutput would be "JANUary".

    If the toggle is false, it sets the text of lblOutput to the concatenation of strF in lowercase and strB in uppercase. However, since the toggle is true in this case, this branch of the if statement is not executed.

    Rate this question:

  • 10. 

       The function ToUpper() converts a string to upper case.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The explanation for the given correct answer is that the function ToUpper() indeed converts a string to upper case. This means that if you pass a string as an argument to the ToUpper() function, it will return the same string but with all the characters converted to uppercase letters. Therefore, the statement "The function ToUpper() converts a string to upper case" is true.

    Rate this question:

  • 11. 

    Consider the following declaration:Dim foobar as String = "bookkeeper"What is the value of foobar after the following statement?foobar = foobar.replace("bo", "zo")

    Correct Answer
    zookkeeper
    Explanation
    The value of foobar after the statement "foobar = foobar.replace("bo", "zo")" is "zookkeeper". The replace() function is used to replace all occurrences of a specified substring with another substring. In this case, it replaces all occurrences of "bo" with "zo" in the string "bookkeeper", resulting in the string "zookkeeper".

    Rate this question:

  • 12. 

    Consider the following declaration:Dim str as String = "success"What is the value of str after the following statement?str = str.Trim("s")

    Correct Answer
    ucce
    Explanation
    The given code declares a variable "str" of type String and assigns it the value "success". The next statement "str = str.Trim("s")" trims the letter "s" from the string. So, after executing this statement, the value of "str" will be "ucce".

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 18, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Jan 29, 2014
    Quiz Created by
    KretschK

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.