Software Fundamentals Ultimate Quiz! Trivia

40 Questions | Total Attempts: 820

SettingsSettingsSettings
Please wait...
Software Fundamentals Ultimate Quiz! Trivia

.


Questions and Answers
  • 1. 
    You need to gain a better understanding of the solution before writing the program. You decide to develop an algorithm that lists all necessary steps to perform an operation in the correct order. Any technique that you use should minimize complexity and ambiguity. Which of the following techniques should you use?
    • A. 

      Flowchart

    • B. 

      Decision table

    • C. 

      C# program

    • D. 

      A paragraph in English

  • 2. 
    Which of the following languages is not considered a high-level programming language?
    • A. 

      C#

    • B. 

      Visual Basic

    • C. 

      Common Intermediate Language

    • D. 

      C++

  • 3. 
    You are writing code for a business application by using C#. You write the following statement to declare an array:   int[] numbers = { 1, 2, 3, 4, 5 };   Now, you need to access the second item in this array (the number 2). Which of the following expression should you use?
    • A. 

      Numbers[0]

    • B. 

      Numbers[1]

    • C. 

      Numbers[2]

    • D. 

      Numbers[3]

  • 4. 
    You are developing a C# program. You write the following code:   int x = 10; int y = ++x; int z = y++;   What will be the value of the variable z after all the above statements are executed?  
    • A. 

      10

    • B. 

      11

    • C. 

      12

    • D. 

      13

  • 5. 
    You are writing a method named PrintReport that doesn’t return a value to the calling code. Which keyword should you use in your method declaration to indicate this fact?    
    • A. 

      Void

    • B. 

      Private

    • C. 

      Int

    • D. 

      String

  • 6. 
    You need to provide complex multi-way branching in your C# program. You need to make sure that your code is easy to read and understand. Which of the following C# statements should you use?
    • A. 

      Case

    • B. 

      Break

    • C. 

      If-else

    • D. 

      Switch

  • 7. 
    You are writing a C# program that iterates through a collection such as arrays and lists. You need to make sure that you process each item in the collection once. You also need to ensure that your code is easy to read and debug. Which of the following C# statements provide the best solution for this requirement?
    • A. 

      While

    • B. 

      For

    • C. 

      Foreach

    • D. 

      Do-while

  • 8. 
    You are developing a C# program that needs to perform 5 iterations. You write the following code:   01: int count = 0; 02: while (count <= 5) 03: { 04: Console.WriteLine("The value of count = {0}", count); 05: count++; 06: }   When you run the program, you notice that the loop does not iterate five times. What should you do to make sure that the loop is executed exactly five times?  
    • A. 

      Change the code in line 01 to int count = 1;

    • B. 

      Change the code in line 02 to: while (count == 5)

    • C. 

      Change the code in line 02 to while (count >= 5)

    • D. 

      Change the code in line 05 to ++count;

  • 9. 
    You are developing a C# program. You write the following code line:   int x = 6 + 4 * 4 / 2 - 1;   What will be the value of the variable x after this statement is executed?  
    • A. 

      19

    • B. 

      13

    • C. 

      20

    • D. 

      14

  • 10. 
    You are writing a C# program that needs to manipulate very large integer values that may exceed 12 digits. The values can be positive or negative. Which data type should you use to store a variable like this?
    • A. 

      Int

    • B. 

      Float

    • C. 

      Double

    • D. 

      Long

  • 11. 
    You have written a C# method that opens a database connection by using the SqlConnect object. The method retrieves some information from the database and then closes the connection. You need to make sure that your code fails gracefully when there is a database error. To handle this situation, you wrap the database code in a try-catch-finally block. You use two catch blocks—one to catch the exceptions of type SqlException and the second to catch the exception of type Exception. Which of the following places should be the best choice for closing the SqlConnection object?
    • A. 

      Inside the try block, before the first catch block

    • B. 

      Inside the catch block that catches SqlException objects

    • C. 

      Inside the catch block that catches Exception objects

    • D. 

      Inside the finally block

  • 12. 
    You are assisting your colleague in solving a compiler error that his code is throwing. Following is the problematic portion of his code:   try { bool success = ApplyPicardoRotation(100, 0); // additional code lines here } catch(DivideByZeroException dbze) { //exception handling code } catch(NotFiniteNumberException nfne) { //exception handling code } catch(ArithmeticException ae) { //exception handling code } catch(OverflowException oe) { //exception handling code }   To remove the compilation error, which of the following ways should you suggest rearranging the code?
    • A. 

      Try { bool success = ApplyPicardoRotation(100, 0); // additional code lines here } catch(DivideByZeroException dbze) { //exception handling code } catch(ArithmeticException ae) { //exception handling code } catch(OverflowException oe) { //exception handling code }

    • B. 

      Try { bool success = ApplyPicardoRotation(100, 0); // additional code lines here } catch(DivideByZeroException dbze) { //exception handling code } catch(Exception e) { //exception handling code } catch(OverflowException oe) { //exception handling code }

    • C. 

      Try { bool success = ApplyPicardoRotation(100, 0); // additional code lines here } catch(DivideByZeroException dbze) { //exception handling code } catch(NotFiniteNumberException nfne) { //exception handling code } catch(OverflowException oe) { //exception handling code } catch(ArithmeticException ae) { //exception handling code }

    • D. 

      Try { bool success = ApplyPicardoRotation(100, 0); // additional code lines here } catch(DivideByZeroException dbze) { //exception handling code } catch(NotFiniteNumberException nfne) { //exception handling code } catch(Exception e) { //exception handling code } catch(ArithmeticException ae) { //exception handling code }

  • 13. 
    You are developing a C# program. You write a recursive method to calculate the factorial of a number. Which of the following code segment should you use to generate correct results?
    • A. 

      Public static int Factorial(int n) { if (n == 0) { return 1; } else { return n * Factorial(n - 1); } }

    • B. 

      Public static int Factorial(int n) { if (n == 0) { return 1; } else { return (n – 1) * Factorial(n); } }

    • C. 

      Public static int Factorial(int n) { if (n == 0) { return n; } else { return Factorial(n - 1); } }

    • D. 

      Public static int Factorial(int n) { return n * Factorial(n - 1); }

  • 14. 
    You are developing a C# program. You write the following code:   01: int count = 0; 02: while (count < 5) 03: { 04: if (count == 3) 05: break; 06: count++; 07: } How many times will the control enter the while loop?  
    • A. 

      5

    • B. 

      4

    • C. 

      3

    • D. 

      2

  • 15. 
    You are developing a C# program. You write the following code:   int i = 6; do { if (i == 3) break; Console.WriteLine("The value of i = {0}", i); i++; } while (i <= 5);   How many times will the control enter the while loop?  
    • A. 

      0

    • B. 

      1

    • C. 

      2

    • D. 

      3

  • 16. 
    You are writing a C# program and need to select an appropriate repetition structure for your requirement. You need to make sure that the test for the termination condition is performed at the bottom of the loop rather than at the top. Which repetition structure should you use?  
    • A. 

      The while statement

    • B. 

      The for statement

    • C. 

      The foreach statement

    • D. 

      The do-while statement

  • 17. 
    You are writing a C# program. You write the following method:   public static void TestSwitch(int op1, int op2, char opr) { int result; switch (opr) { case '+': result = op1 + op2; case '-': result = op1 - op2; case '*': result = op1 * op2; case '/': result = op1 / op2; default: Console.WriteLine("Unknown Operator"); return; } Console.WriteLine("Result: {0}", result); return; }   However, when you compile this code, you get the following error message: Control cannot fall through from one case label to another How should you modify the code to make sure that it compiles successfully?  
    • A. 

      After each case, add the following code line: break;

    • B. 

      After each case, add the following code line: continue;

    • C. 

      After each case, add the following code line: goto default;

    • D. 

      After each case, add the following code line: return;

  • 18. 
    You are developing an algorithm for a retail Web site. You need to calculate discounts on certain items based on the quantity purchased. You develop the following decision table to calculate the discount: Quantity < 10 Y N N N Quantity < 50 Y Y N N Quantity < 100 Y Y Y N Discount 5% 10% 15% 20% If a customer buys 50 units of an item, what discount will be applicable to the purchase?  
    • A. 

      5 percent

    • B. 

      10 percent

    • C. 

      15 percent

    • D. 

      20 percent

  • 19. 
    You are developing an algorithm before you write the C# program. You need to perform some calculations on a number. You develop the following flowchart for the calculation:   If the input value of n is 5, what is the output value of the variable fact according to this flowchart?
    • A. 

      720

    • B. 

      120

    • C. 

      24

    • D. 

      6

  • 20. 
    You are writing a C# program that needs to iterate a fixed number of times. You need to make sure that your code is easy to understand and maintain even when the loop body contains complex code. Which of the following C# statements provide the best solution for this requirement?  
    • A. 

      While

    • B. 

      For

    • C. 

      Foreach

    • D. 

      Do-while

  • 21. 
    You are developing code for a method that calculates the discount for the items sold. You name the method CalculateDiscount. The method defines a variable, percentValue of the type double. You need to make sure that percentValue is accessible only within the CalculateDiscount method. What access modifier should you use when defining the percentValue variable?
    • A. 

      Private

    • B. 

      Protected

    • C. 

      Internal

    • D. 

      Public

  • 22. 
    You are developing code that defines an InitFields method. The method takes two parameters of data type double and does not return any value to the calling code. Which of the following code segments would you use to define the InitFields method?
    • A. 

      Public double InitFields(double l, double w) { length = l; width = w; return length * width; }

    • B. 

      Public void InitFields(double l, double w) { length = l; width = w; }

    • C. 

      Public void InitFields(double l) { length = l; width = l; return; }

    • D. 

      Public double InitFields(double l, double w) { length = l; width = w; }

  • 23. 
    You created a class named GeoShape. You defined a method called Area in the GeoShape class. This method calculates the area of a geometric shape. You want the derived classes of GeoShape to supersede this functionality to support the area calculation of additional geometric shapes. When the method Area is invoked on a GeoShape object, the area should be calculated based on the runtime type of the GeoShape object. Which keyword should you use with the definition of the Area method in the GeoShape class?  
    • A. 

      Abstract

    • B. 

      Virtual

    • C. 

      New

    • D. 

      Overrides

  • 24. 
    Suppose that you defined a class Scenario that defines functionality for running customized pivot transform on large data sets. You do not want the functionality of this class to be inherited into derived classes. What keyword should you use to define the Scenario class?  
    • A. 

      Sealed

    • B. 

      Abstract

    • C. 

      Private

    • D. 

      Internal

  • 25. 
    You need to provide printing functionality to several of your classes. Each class’s algorithm for printing will likely be different. Also, not all the classes have an “is-a” relationship with each other. How should you support this functionality?  
    • A. 

      Add the print functionality to a base class with the public access modifier.

    • B. 

      Have all classes inherit from an abstract base class and override the base-class method to provide their own print functionality.

    • C. 

      Have all the classes inherit from a base class that provides the print functionality.

    • D. 

      Create a common interface that all classes implement.

Back to Top Back to top