C# CH 1-7

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Which logical operator (op) is defined by the following table? (T and F denote true and false.) P Q P, op Q, T T T, T F F, F T F, F F F

AND

.NET is considered a powerful development environment because:

All of the above.

What would be an appropriate declaration for a memory location to be used as a flag to indicate whether a value has reached its upper limit?

bool upperLimit;

The following is probably an example of a: DisplayInstructions( );

call to a void method

Objects are instances of .

classes

Types are implemented in C# using:

classes [[[types = different TYPES of numbers - they are in blue, - int, double, bool] double and bool = floating type

The program that translates high-level programming language into machine-readable form is a(n):

compiler

If you intend to place a block of statements within an if statement, you must use around the block.

curly braces

Which of the following formats 86 to display with two digits to the right of the decimal? a. {0:C} b. {0:c} c. {0:f2} d. all of the above e. none of the above (********GO LOOOK AT 16-29 on ch.2)

d. all of the above

Properties are associated with the _______of the class while methods are affiliated with the ______of the class.

data behavior

The following strategy reduces the amount of time in development and produces more efficient solutions:

design the solution before coding

After designing your solution, you should before typing any code.

desk-check the solution

Incorrect use of spacing with an if statement:

distracts away from the readability

If a loop body must be executed at least once, which loop structure would be the best option?

do...while

One of primary differences between float, double, and decimal is:

double does not require suffixing a numeric literal with a value such as 'm' or 'f'.

Cycling back to previous phases as potential problems are uncovered is an example of:

iterative development

Variables needed only inside a method should be defined as

local variables

You run a program and it gives you the difference of two values as the output, instead of the sum of the values, as intended. This is what type of error?

logic

Functions or modules found in other languages are similar to in C#.

methods

With a UML class diagram

methods show the return type on the diagram

A(n) groups semantically related types under a single name.

namespace

System is an example of a(n):

namespace

What operator is used to instantiate the class

new

In order to provide a new definition for the ToString( ) method, what keyword is added to the method heading?

override

Adding the keyword const to a declaration:

places a value in memory that cannot be changed

Which of the following modifiers is the most restrictive?

private

Instance variables are the same as:

private member data

Normally, member data uses a access modifier, and methods use a access modifier for object-oriented solutions.

private, public

A(n) is a mock-up of desired output.

prototype

Properties are defined with ________access mode.

public

Which of the following modifiers in C# is used with constructors?

public

Given the Employee class shown below, which of the following would be the most appropriate heading for its default constructor? public class Employee {

public Employee( )

Given the following statement, what would be the best heading for the DetermineAnswer( ) method? int aValue, result; result = DetermineAnswer(27.83, aValue);

public int DetermineAnswer(double v1, int v2)

Given the call to the method ComputeCost( ) shown below, which of the following would be the most appropriate heading for the method? The variable someValue is declared as an int. someValue = ComputeCost(27.3);

public static int ComputeCost(double aValue)

Given the following task, which would be the most appropriate method heading? Results have been calculated for taxAmount and totalSales. Write a method heading that accepts these values as input for display purposes.

public static void DisplayResults(double taxAmount, double totalSales )

Given the following task, which would be the most appropriate method heading? A method displays three integer values formatted with currency.

public static void DisplayValues(int v1, int v2, int v3)

The operator represents the logical AND.

&&

Which beginning symbol(s) indicates the following lines will be comments?

/*

What does the following program segment display? int f = 7, s = 15; f = s % 2; if (f != 1) { f = 0; s = 0; } else if (f == 2) { f = 10; s = 10; } else { f = 1; s = 1; } Console.WriteLine(" " + f + " " + s);

1 1

To write a sentinel-controlled loop to compute the average temperature during the month of July in Florida, the best option for a sentinel value would be:

1000

After execution of the following code, what will be the value of inputValue? int inputValue = 0; if (inputValue > 5) inputValue += 5; else if (inputValue > 2) inputValue += 10; else inputValue += 15;

15

What is the result of the following conditional expression when aValue = 100 and bValue = 7? result = aValue > bvalue + 100 ? 1000 : 2000;

2000

Consider the following if statement, which is syntactically correct, but uses poor style and indentation: if (x >= y) if (y > 0) x = x * y; else if (y < 4) x = x - y; Assume that x and y are int variables containing the values 9 and 3, respectively, before execution of the preceding statement. After execution of the statement, what value does x contain?

27

Whatisstoredinansasaresultofthearithmeticexpression,giventhefollowingdeclarations? int ans = 10, v1 = 5, v2 = 7, v3 = 18; ans += v1 + 10 Ã (v2ÀÀ / 5) + v3 / v2;

27

What is the output for total after the following segment of code executes? int num = 4, total = 0; switch (num) { case 1: case 2: total = 5; break; case 3: total = 10; break; case 4: total = total + 3; break; case 8: total = total + 6; break; default: total = total + 4; break; } Console.WriteLine("The value of total is " + total);

3

An object of the int class is:

47

Whatisstoredinansasaresultofthearithmeticexpression,giventhefollowingdeclarations? int ans = 0, v1 = 10, v2 = 19; ans = --v2 % v1++;

8 (--v2 --> means 19-1 = 18/10=1 remainder 8) if it is after don't do anything till after v2++)

In which phase of the software development process would probing questions be used to verify the problem definition?

Analysis

Given the following segment of code, what will be the output? int x = 5; if (x == 2) Console.WriteLine("Brown, brown, run aground."); else Console.WriteLine("Blue, blue, sail on through."); Console.WriteLine("Green, green, nice and clean.");

Blue, blue, sail on through Green, green, nice and clean

With the object-oriented methodology, the data members are referred to as:

attributes or characteristics

Which of the following is a call to a method?

Console.Write("ok");

Which of the following is a valid method call for DetermineHighestScore? void DetermineHighestScore(int val1, int val2)

DetermineHighestScore(val1, val2) [[[[method call = don't have keywords]]]

Which of the following identifiers follows the standard naming convention for naming a class?

Employee

Which of the following would be a valid call to the default constructor for the following class? public class Employee {

Employee employee1 = new Employee( );

Which of the following would be a valid call to a method defined as shown below? public static void InitializeValues( )

InitializeValues( );

What is the name of the feature in Visual Studio that displays in a scrollable list all available methods and properties when the dot is typed after an object name?

IntelliSense

Which of the following statements about logical operators is correct?

Logical OR yields true if either or both of the operands are true

Which of the following identifiers follows the standard naming convention for a method?

PrintReport

After completing the called method's body, control is returned:

back to the location in the calling method that made the call

If you follow the standard C# naming conventions, the property name for the following instance variable would be: private string name;

Name

What is the signature of the following method? public void SetNoOfSquareYards(double squareYards) {noOfSquareYards = squareYards;}

SetNoOfSquareYards(double) [[[[signature of method = METHOD NAME + PARAMETER http://i.stack.imgur.com/NLlbQ.png

The fully qualified call to the method that allows the user to input a single character is:

System.Console.Read( )

What is displayed when the following code executes? score = 40; if (score > 95) Console.WriteLine("Congratulations!"); Console.WriteLine("That's a high score!"); Console.WriteLine("This is a test question!");

That's a high score!

Which of the following is one of the user-defined methods inherited from the object class?

ToString( )

ASP.NET creates which type of application?

Web

What will be displayed from executing the following segment of code? You may assume testScore has a value of 90. int testScore; if (testScore < 60); // Note the semicolon. Console.WriteLine("You failed the test!"); if (testScore > 60) Console.WriteLine("You passed the test!"); else Console.WriteLine("You need to study for " + "the next test!");

You passed the test!

Which escape sequence can be used to indicate the cursor should advance to the next line?

\n

Which expression is evaluated first in the following statement? if ( a > b && c == d || a == 10 && b > a + 7)?

a + 7

The string data type can be used: a. as an operand for the == or != b. as an expression in the switch statement to be evaluated c. as an operand for the > or < operator d. a and b are correct e. all of the above

a and b are correct

The following is probably an example of a(n). public double GetYards( )

accessor

The character that cannot be used with an identifier is:

all of the above

Which of the following would be the most appropriate way to invoke the predefined Floor( ) method found in the Math class? public static double Floor (double)

answer = Math.Floor(87.2);

Which of the following would be the most appropriate way to invoke the CalculateAvg( ) method found in the Student class if an object named gradStudent had been instantiated from the class? public double CalculateAvg(double,double)

answer = gradStudent.CalculateAvg(87.2, 90); [[[[answer = OBJECT.METHOD (values,values,)]]]]]

Examine the code to complete the following question. (Be careful.) if (A == B); C = 3;

every time the program is executed

Which of the following is a valid identifier?

exampleOfAValue

To see the results of an application, you ___ the code.

execute

If you follow the standard C# naming conventions, the local variable names:

follow the camel case convention

If a loop body uses a numeric value that is incremented by three with each iteration through the loop until it reaches 1000, which loop structure would probably be the best option?

for

Which loop structure can only be used with a collection or array?

foreach

If a method is to be used to enter two values that will be used later in the program, which of the following would be the most appropriate heading and call?

heading: public void InputValues(out int val1, out int val2) call: InputValues(out val1, out val2); ***calls never have the int in it?

Which statement in C# allows you to do the following: properly check the variable code to determine whether it contains the character C, and if it does, display ''This is a check'' and then advance to a new line?

if (code == 'C') Console.WriteLine ("This is a check");

Given the switch statement, which of the following would be the first if statement to replace the first test in the switch? switch (control) { case 11 : Console.WriteLine("eleven"); break; case 12 : Console.WriteLine("twelve"); break; case 16 : Console.WriteLine("sixteen"); break; }

if (control == 11)

Which of the following is not a modifier in C#?

int

Which of the following is a valid overloaded method for CalculateAvg( )? int CalculateAvg(int val1, int val2)

int CalculateAvg(double val1, double val2)

Which of the following is a reserved keyword?

int [[remember any keyword = in blue]]

The number 768 is an example of a type.

integral

Given the following class definition, what would be a valid heading for a mutator? public class Student { private string name; private double gpa; }

public void SetGpa(double gpaValue)

Which statement increases the result by 15?

result += 15;

Given the following method definition, what would be a valid call? The variable someIntValue is defined as an int. public static int GetData(out int aValue, ref int bValue)

someIntValue = GetData(out aValue, ref bValue); [[[[[[NEVER INCLUDE INT IN THE CALL]]]]

Given the following task, which would be the most appropriate method heading? A method receives three whole numbers as input. The values represent grades. They should be unchangeable in the method. The method should return the average with a fractional component.

static double DetermineGrade(int grade1, int grade2, int grade3)

Which of the following is a reference type?

string

Which of the following is a valid declaration for a variable to store the name of this textbook?

string bookName;

Loops are needed in programming languages:

to allow statements to be repeated

The result of the expression if (aValue == 10) is:

true or false

The symbol (=) is:

used as part of an assignment statement

Which of the following is a keyword?

using

Which of the following is placed in a method heading to indicate that no value will be returned?

void

For a class called Account that has data members of accountNumber, balance, and transactionAmount, which would be the most appropriate instance method heading for a method that reduces the transaction amount from the current balance?

void ReduceAccount( )

To mark the beginning and end of a block of code, C# programmers use:

{ }


संबंधित स्टडी सेट्स

Chapter 20 the French and American revolutions

View Set

Said Orientalism Questions INTS 407

View Set

Pearson VUE: Casualty Insurance Practice Exam

View Set

Wireless Client Authentication Portals

View Set

*** Question Stems and Conclusion/Evidence Indicators

View Set