Wednesday, May 14, 2008

Java Faqs

1. What is a transient variable?

A transient variable is a variable that may not be serialized.

2. Which containers use a border Layout as their default layout?

The window, Frame and Dialog classes use a border layout as their default layout.

3. Why do threads block on I/O?

Threads block on I/O (that is enters the waiting state) so that other threads may execute while the I/O Operation is performed.

4. How are Observer and Observable used?

Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects.

5. What is synchronization and why is it important?

With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object's value. This often leads to significant errors.

6. Can a lock be acquired on a class?

Yes, a lock can be acquired on a class. This lock is acquired on the class's Class object.

7. What's new with the stop(), suspend() and resume() methods in JDK 1.2?

The stop(), suspend() and resume() methods have been deprecated in JDK 1.2.8. Is null a keyword?The null value is not a keyword.

9. What is the preferred size of a component?

The preferred size of a component is the minimum component size that will allow the component to display normally.

10. What method is used to specify a container's layout?

The setLayout() method is used to specify a container's layout.

11. Which containers use a FlowLayout as their default layout?

The Panel and Applet classes use the FlowLayout as their default layout.

12. What state does a thread enter when it terminates its processing?

When a thread terminates its processing, it enters the dead state.

13. What is the Collections API?

The Collections API is a set of classes and interfaces that support operations on collections of objects.

14. which characters may be used as the second character of an identifier, but not as the first character of an identifier?

The digits 0 through 9 may not be used as the first character of an identifier but they may be used after the first character of an identifier.

15. What is the List interface?

The List interface provides support for ordered collections of objects.

16. How does Java handle integer overflows and underflows?

It uses those low order bytes of the result that can fit into the size of the type allowed by the operation.

17. What is the Vector class?

The Vector class provides the capability to implement a growable array of objects

18. What modifiers may be used with an inner class that is a member of an outer class?

A (non-local) inner class may be declared as public, protected, private, static, final, or abstract.

19. What is an Iterator interface?

The Iterator interface is used to step through the elements of a Collection.

20. What is the difference between the >> and >>> operators?

The >> operator carries the sign bit when shifting right. The >>> zero-fills bits that have been shifted out.

21. Which method of the Component class is used to set the position and size of a component?

setBounds()

22. How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?

Unicode requires 16 bits and ASCII require 7 bits. Although the ASCII character set uses only 7 bits, it is usually represented as 8 bits. UTF-8 represents characters using 8, 16, and 18 bit patterns. UTF-16 uses 16-bit and larger bit patterns.

23 What is the difference between yielding and sleeping?

When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep() method, it returns to the waiting state.

24. Which java.util classes and interfaces support event handling?

The EventObject class and the EventListener interface support event processing.

25. Is sizeof a keyword?

The sizeof operator is not a keyword.

26. What are wrapper classes?

Wrapper classes are classes that allow primitive types to be accessed as objects.

27. Does garbage collection guarantee that a program will not run out of memory?

Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.

28. What restrictions are placed on the location of a package statement within a source code file?A package statement must appear as the first line in a source code file (excluding blank lines and comments).

29. Can an object's finalize() method be invoked while it is reachable?

An object's finalize() method cannot be invoked by the garbage collector while the object is still reachable. However, an object's finalize() method may be invoked by other objects.

30. What is the immediate superclass of the Applet class?

Panel

Monday, April 28, 2008

PLSQL INTERVIEW QUESTIONS

21) Procedure and Functions are explicitly executed. This is different from a database trigger. When is a database trigger executed?

1. When the transaction is committed 2. During the data manipulation statement

3. When an Oracle supplied package references thetrigger

4. During a data manipulation statement and when thetransaction is committed

22) Which Oracle supplied package can you use to output values and messages from database triggers, stored procedures and functions within SQL*Plus?

1. DBMS_DISPLAY 2. DBMS_OUTPUT 3. DBMS_LIST 4. DBMS_DESCRIBE

23) What occurs if a procedure or function terminates with failure without being handled? 1. Any DML statements issued by the construct arestill pending and can be committed or rolled back.

2. Any DML statements issued by the construct arecommitted

3. Unless a GOTO statement is used to continueprocessing within the BEGIN section, the constructterminates.

4. The construct rolls back any DML statements issuedand returns the unhandled exception to the callingenvironment.

24) Examine this code BEGIN theater_pck.v_total_seats_sold_overall := theater_pck.get_total_for_year;

END; Q) For this code to be successful, what must be true?1. Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR function must exist only in the body of the THEATER_PCK package.

2. Only the GET_TOTAL_FOR_YEAR variable must exist in the specification of the THEATER_PCK package.

3. Only the V_TOTAL_SEATS_SOLD_OVERALL variable must exist in the specification of the THEATER_PCK package.

4. Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR function must exist in the specification of the THEATER_PCK package.

25) A stored function must return a value based on conditions that are determined at runtime. Therefore, the SELECT statement cannot be hard- coded and must be created dynamically when the function is executed. Which Oracle supplied package will enable thisfeature?

1. DBMS_DDL

2. DBMS_DML

3. DBMS_SYN

4. DBMS_SQL

PLSQL INTERVIEW QUESTIONS

16) Which procedure can be used to create a customizederror message?1. RAISE_ERROR2. SQLERRM3. RAISE_APPLICATION_ERROR 4. RAISE_SERVER_ERROR 17) The CHECK_THEATER trigger of the THEATER table has been disabled. Which command can you issue to enable this trigger? 1. ALTER TRIGGER check_theater ENABLE;2. ENABLE TRIGGER check_theater; 3. ALTER TABLE check_theater ENABLE check_theater; 4. ENABLE check_theater; 18) Examine this database trigger CREATE OR REPLACE TRIGGER prevent_gross_modification{additional trigger information} BEGIN IF TO_CHAR(sysdate, DY) = MON THEN RAISE_APPLICATION_ERROR(-20000, Gross receipts cannot be deleted on Monday); END IF; END; This trigger must fire before each DELETE of theGROSS_RECEIPT table. It should fire only once for the ent. What additional information must you add? 1. BEFORE DELETE ON gross_receipt 2. AFTER DELETE ON gross_receipt 3. BEFORE (gross_receipt DELETE) 4. FOR EACH ROW DELETED FROM gross_receipt 19) Examine this function: CREATE OR REPLACE FUNCTION set_budget (v_studio_id IN NUMBER, v_new_budget IN NUMBER) IS BEGIN UPDATE studio SET yearly_budget = v_new_budgetWHERE id = v_studio_id; IF SQL%FOUND THENRETURN TRUEl;ELSERETURN FALSE;END IF; COMMIT;END;

Which code must be added to successfully compile thisfunction?

1. Add RETURN right before the IS keyword.

2. Add RETURN number right before the IS keyword.

3. Add RETURN boolean right after the IS keyword.

4. Add RETURN boolean right before the IS keyword.

20) Under which circumstance must you recompile the package body after recompiling the packagespecification?

1. Altering the argument list of one of the packageconstructs

2. Any change made to one of the package constructs

3. Any SQL statement change made to one of thepackage constructs

4. Removing a local variable from the DECLARE sectionof one of the package constructs

PLSQL INTERVIEW QUESTIONS

13) Read the following code:

CREATE OR REPLACE FUNCTION get_budget

(v_studio_id IN NUMBER)RETURN number ISv_yearly_budget NUMBER; BEGINSELECT yearly_budgetINTO v_yearly_budgetFROM studioWHERE id = v_studio_id; RETURN v_yearly_budget;

END;

Which set of statements will successfully invoke this function within SQL*Plus? 1. VARIABLE g_yearly_budget NUMBEREXECUTE g_yearly_budget := GET_BUDGET(11);

2. VARIABLE g_yearly_budget NUMBEREXECUTE :g_yearly_budget := GET_BUDGET(11);

3. VARIABLE :g_yearly_budget NUMBEREXECUTE :g_yearly_budget := GET_BUDGET(11);

4. VARIABLE g_yearly_budget NUMBER:g_yearly_budget := GET_BUDGET(11);

14) Read the following code: CREATE OR REPLACE PROCEDURE update_theater (v_name IN VARCHAR v_theater_id IN NUMBER)

IS

BEGIN

UPDATE theater SET name = v_name WHERE id = v_theater_id; END update_theater;

When invoking this procedure, you encounter the error: ORA-000: Unique constraint (SCOTT.THEATER_NAME_UK) violated.

How should you modify the function to handle thiserror?

1. An user defined exception must be declared andassociated with the error code and handled in theEXCEPTION section.

2. Handle the error in EXCEPTION section byreferencing the error code directly.

3. Handle the error in the EXCEPTION section byreferencing the UNIQUE_ERROR predefined exception.

4. Check for success by checking the value ofSQL%FOUND immediately after the UPDATE statement.

15) Read the following code:

CREATE OR REPLACE PROCEDURE calculate_budget IS v_budget studio.yearly_budget%TYPE; BEGIN v_budget := get_budget(11); IF v_budget <> What effect will this have?

1. The GET_BUDGET function will be marked invalid andmust be recompiled before the next execution.

2. The SET_BUDGET function will be marked invalid andmust be recompiled before the next execution.

3. Only the CALCULATE_BUDGET procedure needs to berecompiled.

4. All three procedures are marked invalid and mustbe recompiled.

PLSQL INTERVIEW QUESTIONS

7) what are the commands used to open a CURSOR FOR loop
are --
1. open

2. fetch
3. parse

4. None, cursor for loops handle cursor openingimplicitly.

8) What happens when rows are found using a FETCH statement
1. It causes the cursor to close 2. It causes the cursor to open 3. It loads the current row values into variables 4. It creates the variables to hold the currentrow values

9) Read the following code:
CREATE OR REPLACE PROCEDURE find_cpt (v_movie_id
{Argument Mode} NUMBER, _cost_per_ticket
{argument mode} NUMBER)
IS BEGIN IF v_cost_per_ticket > 8.5 THEN SELECT cost_per_ticket INTO v_cost_per_ticket FROM gross_receipt WHERE movie_id = v_movie_id; END IF; END;

Q) Which mode should be used for V_COST_PER_TICKET?
1. IN
2. OUT
3. RETURN 4. IN OUT

10) Read the following code:
CREATE OR REPLACE TRIGGER update_show_gross {trigger information} BEGIN {additional code} END; The trigger code should only execute when the column, COST_PER_TICKET, is greater than $3.
Which trigger information will you add?
1. WHEN (new.cost_per_ticket > 3.75)

2. WHEN (:new.cost_per_ticket > 3.75

3. WHERE (new.cost_per_ticket > 3.75)

4. WHERE (:new.cost_per_ticket > 3.75)

11) What is the maximum number of handlers processed before the PL/SQL block is exited when an exception occurs?
1. Only one
2. All that apply
3. All referenced

4. None

12) For which trigger timing can you reference the NEW and OLD qualifiers?
1. Statement and Row
2. Statement only

3. Row only

4. Oracle Forms trigger

PlSQl Interview Questions

1) Which of the following statements is true aboutimplicit cursors?

1. Implicit cursors are used for SQL statements thatare not named.

2. Developers should use implicit cursors with greatcare.

3. Implicit cursors are used in cursor for loops tohandle data processing.

4. Implicit cursors are no longer a feature in Oracle.

2) Which of the following is not a feature of a cursorFOR loop?

1. Record type declaration.

2. Opening and parsing of SQL statements.
3. Fetches records from cursor.

4. Requires exit condition to be defined.

3) A developer would like to use referential datatypedeclaration on a variable. The variable name isEMPLOYEE_LASTNAME, and the corresponding table
and column is EMPLOYEE,and LNAME, respectively.

How would the developer define this variable using referential datatypes?

1. Use employee.lname%type.
2. Use employee.lname%rowtype.
3. Look up datatype for EMPLOYEE column on LASTNAMEtable and use that.

4. Declare it to be type LONG.

4) Which three of the following are implicit cursorattributes?
1. %found
2. %too_many_rows3. %notfound
4. %rowcount5. %rowtype

5) If left out, which of the following would cause aninfinite loop to occur in a simple loop?
1. LOOP
2. END LOOP
3. IF-THEN
4. EXIT

6) Which line in the following statement will produce an error?
1. cursor action_cursor is
2. select name, rate, action
3. into action_record
4. from action_table;
5. There are no errors in this statement.