In mathematics, the Nth harmonic number is defined to be 1 + 1/2 + 1/3 + 1/4 + ... + 1/N. So, the first harmonic number is 1, the second is 1.5, the third is 1.83333... and so on. Assume that n is an integer variable whose value is some positive integer N. Assume also that hn is a variable whose value is the Nth harmonic number. Write an expression whose value is the (N+1)th harmonic number.

In mathematics, the Nth harmonic number is defined to be 1 + 1/2 + 1/3 + 1/4 + ... + 1/N. So, the first harmonic number is 1, the second is 1.5, the third is 1.83333... and so on. Assume that n is an integer variable whose value is some positive integer N. Assume also that hn is a variable whose value is the Nth harmonic number. Write an expression whose value is the (N+1)th harmonic number.



Answer: hn + 1.0/(n+1)

In mathematics, the Nth harmonic number is defined to be 1 + 1/2 + 1/3 + 1/4 + ... + 1/N. So, the first harmonic number is 1, the second is 1.5, the third is 1.83333... and so on. Write an expression whose value is the 8th harmonic number.

In mathematics, the Nth harmonic number is defined to be 1 + 1/2 + 1/3 + 1/4 + ... + 1/N. So, the first harmonic number is 1, the second is 1.5, the third is 1.83333... and so on. Write an expression whose value is the 8th harmonic number.



Answer: 1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6 + 1/7 + 1/8

Each of the walls of a room with square dimensions has been built with two pieces of sheetrock, a smaller one and a larger one. The length of all the smaller ones is the same and is stored in the variable small . Similarly, the length of all the larger ones is the same and is stored in the variable large . Write a single expression whose value is the total area of this room. DO NOT any method invocations.

Each of the walls of a room with square dimensions has been built with two pieces of sheetrock, a smaller one and a larger one. The length of all the smaller ones is the same and is stored in the variable small . Similarly, the length of all the larger ones is the same and is stored in the variable large . Write a single expression whose value is the total area of this room. DO NOT any method invocations.



Answer: (small + large) ** 2

The dimensions (width and length) of room1 have been read into two variables : width1 and length1 . The dimensions of room2 have been read into two other variables : width2 and length2 . Write a single expression whose value is the total area of the two rooms.

The dimensions (width and length) of room1 have been read into two variables : width1 and length1 . The dimensions of room2 have been read into two other variables : width2 and length2 . Write a single expression whose value is the total area of the two rooms.



Answer: (width1 length1) + (width2 length2)

Calculate the BMI of a person using the formula BMI = ( Weight in Pounds / ( Height in inches ) x ( Height in inches ) ) x 703 and assign the value to the variable bmi . Assume the value of the weight in pounds has already been assigned to the variable w and the value of the height in inches has been assigned to the variable h . Take care to use floating-point division.

Calculate the BMI of a person using the formula BMI = ( Weight in Pounds / ( Height in inches ) x ( Height in inches ) ) x 703 and assign the value to the variable bmi . Assume the value of the weight in pounds has already been assigned to the variable w and the value of the height in inches has been assigned to the variable h . Take care to use floating-point division.



Answer: bmi = (w/ (h) (h)) 703

Assign the average of the values in the variables a , b , and c to a variable avg . Assume that the variables a , b , and c have already been assigned a value, but do not assume that the values are all floating-point. The average should be a floating-point value.

Assign the average of the values in the variables a , b , and c to a variable avg . Assume that the variables a , b , and c have already been assigned a value, but do not assume that the values are all floating-point. The average should be a floating-point value.



Answer: avg = (a + b + c) / 3

Assume that price is an integer variable whose value is the price (in US currency) in cents of an item. Assuming the item is paid for with a minimum amount of change and just single dollars, write an expression for the amount of change (in cents) that would have to be paid.

Assume that price is an integer variable whose value is the price (in US currency) in cents of an item. Assuming the item is paid for with a minimum amount of change and just single dollars, write an expression for the amount of change (in cents) that would have to be paid.



price % 100

Assume that a variable x has been assigned a integer value,.

You are given two variables , both already defined, one associated with a float and named total_weight , containing the weight of a shipment, the other associated with an int and named quantity , containing the number of items in the shipment. Write an expression that calculates the weight of one item.

You are given two variables , both already defined, one associated with a float and named total_weight , containing the weight of a shipment, the other associated with an int and named quantity , containing the number of items in the shipment. Write an expression that calculates the weight of one item.



Answer: total_weight / quantity

You are given two variables , both already defined. One is named price and is associated with a float and is the price of an order. The other is total_number and is associated with an int and is the number of orders. Write an expression that calculates the total price for all orders.

You are given two variables , both already defined. One is named price and is associated with a float and is the price of an order. The other is total_number and is associated with an int and is the number of orders. Write an expression that calculates the total price for all orders.



Answer: price * total_number

You are given two variables , already defined, named total_weight , containing the weight of a shipment, and weight_of_box , containing the weight of the box in which a product is shipped. Write an expression that calculates the net weight of the product.

You are given two variables , already defined, named total_weight , containing the weight of a shipment, and weight_of_box , containing the weight of the box in which a product is shipped. Write an expression that calculates the net weight of the product.



Answer: total_weight - weight_of_box

A wall has been built with two pieces of sheetrock, a smaller one and a larger one. The length of the smaller one is stored in the variable small . Similarly, the length of the larger one is stored in the variable large . Write a single expression whose value is the length of this wall.

A wall has been built with two pieces of sheetrock, a smaller one and a larger one. The length of the smaller one is stored in the variable small . Similarly, the length of the larger one is stored in the variable large . Write a single expression whose value is the length of this wall.



Answer: small + large

What are logic errors?

What are logic errors?



Answer: errors when a program does not preform the way it was intended to.

When is the code within a catch block executed?

When is the code within a catch block executed?




a. When the code in the try block doesn't compile
b. When the try block finishes executing
c. When a runtime error occurs
d. When the exception specified in the catch block is thrown in the try block


Answer: d. When the exception specified in the catch block is thrown in the try block

You should validate user entries rather than catch and handle exceptions caused by invalid entries whenever possible because

You should validate user entries rather than catch and handle exceptions caused by invalid entries whenever possible because




a. data validation code should only be used for situations that are truly exceptional
b. all of the above
c. you can more accurately determine the cause of an invalid entry
d. your code will run faster


Answer: d. your code will run faster

Exception in thread "main" java.util.InputMismatchException

Exception in thread "main" java.util.InputMismatchException

at java.util.Scanner.throwFor(Scanner.java:818)
at java.util.Scanner.next(Scanner.java:1420)
at java.util.Scanner.nextDouble(Scanner.java:2324)
at FutureValueApp.main(FutureValueApp.java:17)
What is the order of method calls?

a. java.util.Scanner.throwFor calls java.util.Scanner.next calls java.util.Scanner.nextDouble calls FutureValueApp.main
b. FutureValueApp.main calls java.util.Scanner.nextDouble calls java.util.Scanner.next calls java.util.Scanner.throwFor
c. you can't tell from the information given


Answer: b. FutureValueApp.main calls java.util.Scanner.nextDouble calls java.util.Scanner.next calls java.util.Scanner.throwFor

Exception in thread "main" java.util.InputMismatchException

Exception in thread "main" java.util.InputMismatchException

at java.util.Scanner.throwFor(Scanner.java:818)
at java.util.Scanner.next(Scanner.java:1420)
at java.util.Scanner.nextDouble(Scanner.java:2324)
at FutureValueApp.main(FutureValueApp.java:17)
Which statement would you look at to find the source of the problem?



a. line 818 in the Scanner class
b. line 2324 in the Scanner class
c. line 17 in the FutureValueApp class
d. line 1420 in the Scanner class


Answer: c. line 17 in the FutureValueApp class

Exception in thread "main" java.util.InputMismatchException

Exception in thread "main" java.util.InputMismatchException

at java.util.Scanner.throwFor(Scanner.java:818)
at java.util.Scanner.next(Scanner.java:1420)
at java.util.Scanner.nextDouble(Scanner.java:2324)
at FutureValueApp.main(FutureValueApp.java:17)
What caused the exception to occur?



a. You can't tell from the information given.
b. The user didn't enter the type of data the program was expecting.
c. The program couldn't format the double value that the user entered.


Answer: b. The user didn't enter the type of data the program was expecting.

Exception in thread "main" java.util.InputMismatchException

Exception in thread "main" java.util.InputMismatchException

at java.util.Scanner.throwFor(Scanner.java:818)
at java.util.Scanner.next(Scanner.java:1420)
at java.util.Scanner.nextDouble(Scanner.java:2324)
at FutureValueApp.main(FutureValueApp.java:17)
What is this output called?



a. a method log
b. a stack trace
c. an exception handler
d. an exception hierarchy


Answer: b. a stack trace

You should validate user entries rather than catch and handle exceptions caused by invalid entries whenever possible because

You should validate user entries rather than catch and handle exceptions caused by invalid entries whenever possible because


a. all of the above
b. data validation code should only be used for situations that are truly exceptional
c. your code will run faster
d. you can more accurately determine the cause of an invalid entry


Answer: c. your code will run faster

When is the code within a catch block executed?

When is the code within a catch block executed?




a. When the exception specified in the catch block is thrown in the try block
b. When the try block finishes executing
c. When the code in the try block doesn't compile
d. When a runtime error occurs


Answer: a. When the exception specified in the catch block is thrown in the try block

What is the main reason for using a generic data validation method?

What is the main reason for using a generic data validation method?




a. It runs faster than validation code in the main method.
b. It saves you from writing variations of the same code again and again to check multiple data entries.
c. It prevents NumberFormatExceptions from being thrown.
d. None of the above.



Answer: b. It saves you from writing variations of the same

To handle an exception using the try statement, you must

To handle an exception using the try statement, you must




a. code a try block around the statement that may throw the exceptions
b. code a finally block that contains the statements that will be executed at the end of the try statement
c. code a catch block that contains the statements that you want to be executed when the exception occurs
d. all of the above
e. a and c only


Answer: e. a and c only

To determine the cause of an unhandled exception, you can

To determine the cause of an unhandled exception, you can




a. use the name of the exception class that's displayed
b. use the error message that's displayed
c. use the information in the stack trace
d. all of the above


Answer: d. all of the above

The has methods of the Scanner class let you

The has methods of the Scanner class let you




a. check if the user has entered data at the console
b. check if the data entered at the console can be converted to a specific data type
c. retrieve and discard data that isn't required by the application
d. all of the above
e. a and b only


Answer: e. a and b only

Which statement dynamically assigns an image named car in the drawable folder to an ImageView control?

Which statement dynamically assigns an image named car in the drawable folder to an ImageView control?




a. ​car.setImageResource(R.drawable.image);​
b. image.setImageResource(R.drawable.car);​
c. ​image.setImageResource(car.R.drawable);​
d. SetImageResource.image(R.drawable.car);​


Answer: b. image.setImageResource(R.drawable.car);​

Which of the following correctly completes the statement below to instantiate a SharedPreferences object?

Which of the following correctly completes the statement below to instantiate a SharedPreferences object?


SharedPreferences sharedPref =


a. PreferenceManager.getDefaultSharedPreferences(this);
b. SharedPreferences.PreferenceManager.getDefault(this);
c. SharedPreferences.getDefaultPreferenceManager(this);
d. PreferenceManager.SharedPreferences.getDefault(this);


Answer: a. PreferenceManager.getDefaultSharedPreferences(this);

What does the abbreviation SQL stand for?

What does the abbreviation SQL stand for?




a. Structured Quorum List
b. Simple Quorum Language
c. Simple Query List
d. Structured Query Language


Answer: d. Structured Query Language

Where is the strings.xml file located?

Where is the strings.xml file located?




a. res/drawable-mdpi folder
b. res/layout folder
c. res/values folder
d. res/drawable-hdpi folder


Answer: c. res/values folder

What does the acronym URL stand for?

What does the acronym URL stand for?




a. Uniform Resource Locator
b. Usual Random Lesson
c. Universal Redirection Locale
d. Utility Rendering Logo


Answer: a. Uniform Resource Locator

The term ____ refers to the process of verifying that your HTML5 (or XHTML) document is well formed, and checking that the elements in your document are correctly written according to the element definitions in a specific DTD.

The term ____ refers to the process of verifying that your HTML5 (or XHTML) document is well formed, and checking that the elements in your document are correctly written according to the element definitions in a specific DTD.


a. validation
b. parsing
c. interpreting
d. recognizing


Answer: a. validation

CSS styles consist of rule sets applied to HTML elements by their selectors (e.g., body, h1, p, .myclass, #myid, etc.). However, a single rule consists of a property and its value, separated by a ____.

CSS styles consist of rule sets applied to HTML elements by their selectors (e.g., body, h1, p, .myclass, #myid, etc.). However, a single rule consists of a property and its value, separated by a ____.


a. colon
b. comma
c. semicolon
d. forward slash


Answer: a. colon

In the following rule set, h1 is the

In the following rule set, h1 is the


h1
{
font-size: 700;
color: black;
background-color: yellow;
margin: 10px;
}

a. rule
b. selector
c. property
d. value
e. declaration


Answer: b. selector

One benefit of using external style sheets with the @import method is that

One benefit of using external style sheets with the @import method is that


a. it is more efficient than using the link method.
b. it uses less code than using the link method.
c. it requires fewer round trips than using the link method.
d. it is easier to implement into an existing style sheet when working with a large number of files.


Answer: d. it is easier to implement into an existing style sheet when working with a large number of files.

To use the styles in an external style sheet,

To use the styles in an external style sheet,


a. you use the Style attribute of a document head to identify the style sheet
b. you use the Link attribute of an element to identify the style sheet
c. you use the Link element of a document head to identify the style sheet
d. you use the Style attribute of an element to identify a specific style rule


Answer: c. you use the Link element of a document head to identify the style sheet

To code a selector for an HTML element, you code

To code a selector for an HTML element, you code


a. the element name preceded by a pound sign (#)
b. the element name preceded by a semicolon
c. the element name preceded by a period
d. the element name


Answer: d. the element name

Which of the following statements is true?

Which of the following statements is true?


a. The Label control has a TabStop property, but can't accept focus.
b. The Label control has a TabStop property, but it is ignored.
c. The Label control doesn't have a TabStop property.
d. The Label control has a TabStop property and can accept focus.



Answer: c. The Label control doesn't have a TabStop property.

What is the purpose of the Common Language Runtime?

What is the purpose of the Common Language Runtime?


a. it provides pre-written code that can be used by .NET applications
b. it manages the execution of .NET applications
c. it specifies the format of compiled .NET applications
d. it specifies the data types that can be used by .NET applications


Answer: b. it manages the execution of .NET applications

What is the purpose of the .NET Framework Class Library?

What is the purpose of the .NET Framework Class Library?


a. it manages the execution of .NET applications
b. it specifies the data types that can be used by .NET applications
c. it provides pre-written code that can be used by .NET applications
d. it specifies the format of compiled .NET applications


Answer: c. it provides pre-written code that can be used by .NET applications

To select two or more controls, you can

To select two or more controls, you can


a. hold down either the Shift or Ctrl key while you click on them
b. drag an outline around the controls while you're holding down the Alt key
c. hold down the Shift key while you click on them
d. hold down the Ctrl key while you click on them


Answer: a. hold down either the Shift or Ctrl key while you click on them

To create an access key that will move the focus to a text box, you

To create an access key that will move the focus to a text box, you


a. set the AccessKey property of the text box
b. set the access key in the Text property of the text box
c. set the access key in the Text property of the label immediately after the text box
d. set the access key in the Text property of the label immediately before the text box


Answer: d. set the access key in the Text property of the label immediately before the text box

The tab order determines the order in which

The tab order determines the order in which


a. the controls are displayed on the form
b. the user must enter data into the controls on a form
c. the tabs in the Form Designer window are displayed
d. the controls on a form receive focus when the user presses the Tab key


Answer: d. the controls on a form receive focus when the user presses the Tab key

The Text property of a control determines

The Text property of a control determines


a. the name of the control and the text that's displayed in it
b. the name that you use to refer to the control in your C# code
c. the text that's displayed in the control
d. the text that's displayed in the form


Answer: c. the text that's displayed in the control

The .NET Framework Class Library consists of

The .NET Framework Class Library consists of


a. classes that are organized into namespaces
b. solutions that are organized into sublibraries
c. classes that are organized into sublibraries
d. solutions that are organized into namespaces


Answer: a. classes that are organized into namespaces

An assembly is

An assembly is


a. an executable file that includes the MSIL or IL
b. a container that holds projects
c. the source file for a .NET application
d. a secondary file required by an application, such as a graphic image or sound file


Answer: a. an executable file that includes the MSIL or IL

Access keys let the user activate a control by

Access keys let the user activate a control by


a. pressing Alt and Ctrl plus another key
b. pressing Alt plus another key
c. pressing Shift plus another key
d. pressing Ctrl plus another key


Answer: b. pressing Alt plus another key

A solution is

A solution is


a. the source file for a .NET application
b. an executable file that contains MSIL or IL
c. a container that holds projects
d. a secondary file required by an application, such as a graphic image or sound file


Answer: c. a container that holds projects

A Windows Forms application runs

A Windows Forms application runs




a. in a web browser
b. under control of the compiler
c. under the Windows operating system
d. in the console of Visual Studio


Answer: c. under the Windows operating system

Unlike a static web page, a dynamic web page

Unlike a static web page, a dynamic web page




a. can't be displayed in a web browser
b. is created in response to an HTTP request
c. consists of HTML
d. is generated by a program running on an application server


Answer: d. is generated by a program running on an application server

The main purpose of the .NET Framework Class Library is to

The main purpose of the .NET Framework Class Library is to


a. provide the classes that are used for developing .NET applications
b. provide the classes that are needed for developing database applications
c. manage the execution of .NET applications
d. manage the development of the web pages


Answer: a. provide the classes that are used for developing .NET applications

In an Internet development environment, you use an FTP server to

In an Internet development environment, you use an FTP server to


a. transfer files between the client computer and the web server
b. access data on a server other than the web server
c. send an HTTP request to the web server
d. process a request for a dynamic web page


Answer: a. transfer files between the client computer and the web server

You can get context-sensitive help information from the Code Editor by

You can get context-sensitive help information from the Code Editor by


a. selecting Contents from the Help menu
b. selecting Index from the Help menu
c. positioning the insertion point in a keyword and pressing F1
d. selecting Search from the Help menu


Answer: c. positioning the insertion point in a keyword and pressing F1

Which of the following statements is true?

Which of the following statements is true?


a. You can't use C# keywords in a comment.
b. Comments can be inaccurate or out of date.
c. Comments make the program run slower.
d. Comments must appear at the beginning of a line.



Answer: b. Comments can be inaccurate or out of date.

Which of the following is not a recommended way to improve the readability of your C# code?

Which of the following is not a recommended way to improve the readability of your C# code?


a. Use indentation to align related elements of code.
b. Use spaces to separate words, values, and operators.
c. Use all capital letters for variable names.
d. Use blank lines before and after groups of related statements.


Answer: c. Use all capital letters for variable names.

To refer to a property of an object in your C# code, you code the

To refer to a property of an object in your C# code, you code the


a. property name followed by a period and the class name
b. object name followed by a period and the property name
c. property name followed by a period and the object name
d. class name followed by a period and the property name


Answer: b. object name followed by a period and the property name

One common cause of a runtime error is

One common cause of a runtime error is


a. a form that has invalid property settings
b. a user entry that can't be converted to a number
c. a control that has invalid property settings
d. misspelled keywords in the C# code


Answer: b. a user entry that can't be converted to a number

Instantiation is the process of generating

Instantiation is the process of generating


a. a member from a class
b. an instance of an object
c. an object from a class
d. an instance of a member


Answer: c. an object from a class

An object is

An object is


a. an instance of a class
b. code that defines the characteristics of a class
c. a grouping of related classes
d. code for a Windows form


Answer: a. an instance of a class

A syntax error is identified in

A syntax error is identified in


a. the Code Editor window only
b. the Error List window only
c. the Code Editor window and the Error List window


Answer: c. the Code Editor window and the Error List window

A data tip

A data tip


a. displays the value of a variable or property
b. indicates what data will be modified next
c. displays the possible values for a property
d. gives advice on how to set property values


Answer: a. displays the value of a variable or property

A class is

A class is


a. an instance of an object
b. a grouping of related objects
c. code (blueprint or framework) that defines the characteristics of an object
d. code for a Windows form


Answer: c. code (blueprint or framework) that defines the characteristics of an object

What does the following code do? txtMonthlyInvestment.Focus();

What does the following code do?
txtMonthlyInvestment.Focus();




a. calls the Focus method of the txtMonthlyInvestment control
b. calls the () method of the txtMonthlyInvestment.Focus control
c. calls the txtMonthlyInvestment method of the Focus control
d. calls the Focus method of the current form instance


Answer: a. calls the Focus method of the txtMonthlyInvestment control