Sunday, June 30, 2019

Week 10

Multiple Choice: #1 to #10

1.  Which of the following generates a series of integers that can be stored in a database?
            C. a sequence
2.  Which syntax is correct for removing a public synonym?
            C. DROP PUBLIC SYNONYM synonymname;
3.  Which of the following commands can you use to modify an index?
            E. none of the above
4.  Which of the following generates an integer in a sequence?
            A. NEXTVAL
5.  Which of the following is a valid SQL statement?
            E. only a and c
6.  Suppose the user Juan creates a table called MYTABLE with four columns. The first column has a PRIMARY KEY constraint, the second column has a NOT NULL constraint, the third column has a CHECK constraint, and the fourth column has a FOREIGN KEY constraint. Given this information, how many indexes does Oracle 12ccreate automatically when the table and constraints are created?
            D. 3
7.  Given the table created in Question 6, which of the following commands can Juan use to create a synonym that allows anyone to access the table without having to identify his schema in the table reference?
            B. CREATE PUBLIC SYNONYM
            the table
            FOR mytable;
8.  Which of the following statements is true?
            b. Any unassigned sequence values appears in the USER_SEQUENCE data          dictionarytable as unassigned.
9.  When is creating an index manually inappropriate?
            D. all of the above
10. If a column has high selectivity or cardinality, which index type is most appropriate?
            B. B-tree

Hands-on Exercises: #1 to #3

1. Create a sequence for populating the Customer# column of the CUSTOMERS table. When setting the start and increment values, keep in mind that data already exists in this table. The options should be set to not cycle the values and not cache any values, and no minimum or maximum values should be declared.
create sequence customers_customer#_seq
increment by 1
start with 10
nocache
nominvalue
nomaxvalue
nocycle;
2. Add a new customer row by using the sequence created in Question 1. The only data currently available for the customer is as follows: last name = Shoulders, first name =Frank, and zip = 23567.
            insert into customers (customer#, lastname, firstname, zip)
            Values(customers_customer#_seq.NEXTVAL, 'Shoulders', 'Frank', 23567);
3. Create a sequence that generates integers starting with the value 5. Each value should be three less than the previous value generated. The lowest possible value should be 0, and the sequence shouldnt be allowed to cycle. Name the sequence MY_FIRST_SEQ.
create sequence my_first_seq
increment by -3
start with 5
MINVALUE 0
MAXVALUE 5
NOCYCLE;

Extra credit: Review Questions #1, #2

1. How can a sequence be used in a database?
            Used to generate a series of integers.
2. How can gaps appear in values generated by a sequence?

If values are stored in different tables.
If numbers are cached but not used.
If a rollback occurs.

client
A method that uses another is called a ____ of the method it uses.
private void
When you place a Button named okButton on a Form in the IDE and double-click it, a method is automatically generated with the following header:

____ okButton_Click(object sender, EventArgs e).
static
If you use the keyword modifier ____, you indicate that a method can be called by referring to the class rather than an object from the class.
implementation hiding
With ____, if a programmer changes the way in which a method internally works, programs that use that method will not be affected and will not need to be modified.
accessibility
The optional declared ____ for a method (for example, public) sets limits as to how other methods can use it.
scope
A program element's ____ is the segment of code in which it can be used.
[ ]
You indicate that a method parameter is an array by placing ____ after the data type in the method's parameter list.
multifile assembly
To more easily incorporate methods into a program, it is common practice to store methods in their own classes and files. Then you can add them into any application that uses them. The resulting compound program is called a(n) ____.
public
The ____ accessibility modifier allows access to a method from other classes.
parameter
A method ____ is a variable that holds data passed to the method when it is called; it receives an argument's value when the method executes.
nonstatic
If you create a Click() method that responds to button clicks, it will be ____ by default because it is associated with an object that is a Form.
nested
When method calls are placed inside other method calls, the calls are ____ method calls
mandatory
Any optional parameters in a parameter list must appear to the right of all ____ parameters in the list.
illegal
Methods with identical names that have identical parameter lists but different return types are ____ methods.
reference
When you use a(n) ____ parameter, the argument used to call the method must have an assigned value
Reference
____ parameters act as aliases, or pseudonyms, for the same memory location occupied by the original variable being passed to a method.
reference
On occasion, you might want a method to be able to alter a value you pass to it. In that case, you can use a(n) ____ parameter or an output parameter.
reference
When an array passed to a method is passed by ____, the method receives the actual memory address of the array and has access to the actual values in the array elements.
optional
In C#, parameters can be mandatory or ____.
optional
Omitted ____ arguments are ignored for betterness purposes on argument conversions.
optional
A(n) ____ parameter to a method is one for which a value is automatically supplied if you do not explicitly send one as an argument.
parameter array
When you don't know how many arguments you might eventually send to a method, you can declare a(n) ____
default
If you assign a default value to any variable in a method's parameter list, then all parameters to the right of that parameter must have ____ values.
Objects
In C#, all data types are ____________________.
value
When you use a(n) ____ parameter in a method header, you indicate the parameter's type and name, and the method receives a copy of the value passed to it.
value
A formal parameter that receives a copy of the value passed to it is also an example of a(n) ____ parameter.
value
Only ____ parameters can be given default values.
TryParse()
To avoid data conversion exceptions that occur when a value cannot be converted to an appropriate type, you can use a version of the C# ____ method with an out parameter.
Overloading
____ involves the ability to write multiple versions of a method using the same method name.
colon
You name an argument in a method call using its parameter name and a ____ before the value.
string
Because the ReadLine() method call can be assigned to a string, its return type is ____.
formal
A parameter within a method header is called a(n) ____ parameter
black box
A(n) ____ is a device you can use without knowing how it works internally.
default arguments
The number of arguments does not need to match the number in the parameter list when you use ___
private
The ____ accessibility modifier limits method access to the class that contains the method
ambiguous
Methods are ____ when there is the potential for a situation in which the compiler cannot determine which method to use.
signature
A method's name and parameter list constitute the method's ____.
params
Only one ____ keyword is permitted in a method declaration.
out
You use the keyword ____ as a modifier to indicate an output parameter.
return
A ____ statement causes a value to be sent back to the calling method.
invoke
Methods can ____, or call, other methods; that is, a program uses a method's name and the method performs a job for the class.
output
Using a(n) ____ parameter is convenient when the variable to be passed does not have an assigned value at the time the method is called.
positional
Unnamed method arguments are also known as ____ arguments.
IDE
When you use the Visual Studio ____________________ to create programs, the IntelliSense feature will allow you to discover built-in overloaded methods by displaying all versions of the method when you type in the method name and the parameter list opening parenthesis.
! conversion
! When an int is promoted to a double, the process is called an implicit ____________________ or implicit cast.
! header
! A method ____________________ defines the rules for using the method and can include accessibility, static, and return type modifiers.
! method type
! Every method has a(n) ____________________, indicating what kind of value the method will return to any other method that calls it.
! overload resolution
! When a method call could execute multiple overloaded method versions, C# determines which method to execute using a process called ____________________.
! body
! A method ____________________ is a block of statements that carry out the method's work.
! method
! A(n) ____________________ is an encapsulated series of statements that carry out a task.
! betterness rules
! The rules that determine which method version to call are known as ____________________.
! void
! If a method does not return a value, its return type is ____________________.
false
The type of an argument in a method call must exactly match the type of the corresponding parameter specified in the method declaration.
false
A declaration for a method that receives two or more arguments must list the type for each parameter separately only if the parameters have different types.
False
You cannot use the out or ref keywords when passing an array to a method.
false
To ensure that the original value of an argument passed to a method remains unchanged after returning from the method, you should use a reference parameter or an output parameter.
false
Overloaded methods sharing the same identifier must have the same return type.
false
Arrays, like all objects, are passed by value.
true
If you do not provide an accessibility modifier for a method, it is private by default.
true
When you use a reference parameter, any passed variable must have an assigned value.
true
A method can return, at most, one value to a method that calls it.