In the Linux Bash shell, the ____ key combination deletes the content of the command line from the current cursor position to the end of the command line.
Write a statement that increments total by the value associated with amount . That is, add the value associated with amount to that associated with total and assign the result to total .
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. Write an expression whose value is the 8th harmonic number.
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.
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.
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.
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.
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,.
Assume there is a variable , h already assigned a positive integer value. Write the code necessary to assign its square to the variable g . For example, if h had the value 8 then g would get the value 64
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 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 , 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.
Write an expression that computes the remainder of the variable principal when divided by the variable divisor . (Assume that each is associated with an int .)
Given the variables full_admission_price and discount_amount (already defined), write an expression corresponding to the price of a discount admission.
Given the variables taxable_purchases and tax_free_purchases (which already have been defined), write an expression corresponding to the total amount purchased.
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.
Variables i and j each have associated values. Swap them, so that i becomes associated with j 's original value, and j becomes associated with is original value. You can use two more variables itemp and jtemp
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
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
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
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
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
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
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
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?
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
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
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
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
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?
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's the first step when writing persistent data using a SharedPreferences file?
a. Create a SharedPreferences.Editor object
b. Obtain an instance of the SharedPreferences file
c. Assign values into SharedPreferences objects
d. Save the values to the preferences file
Answer: b. Obtain an instance of the SharedPreferences file
Before an app attempts to connect to a network connection, what action should be taken?
a. The app should scan the quality of the network.
b. No action needs to be taken.
c. The app should see if an Internet connection is available.
d. The app should open a network's web browser.
Answer: c. The app should see if an Internet connection is available.
Which XML code statement places an icon named ic_city.png to the right of the text in a ListView display?
a. android:drawableRight="@drawable/ic_city"
b. icons:drawableRight="@drawable/ic_city"
c. icons:iconRight="@icon/ic_city"
d. android:iconRight="@icon/ic_city"
Answer: a. android:drawableRight="@drawable/ic_city"
What statement should you put at the end of a switch statement if you want a block of code to be executed in the event none of the case statement values matches?
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
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 ____.
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.
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
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
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?
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?
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
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
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
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
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
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
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
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
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
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
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
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
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?
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
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
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
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. 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();
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