Object Oriented - Interview Questions: What Is OOP?
Object Oriented - Interview Questions: What Is OOP?
The object oriented programming is commonly known as OOP. Most of the languages are developed using OOP concept. Object-oriented programming (OOP) is a programming concept that uses "objects" to develop a system. A programming object has an ability to perform actions and has attributes. It performs just like real world entities for e.g. a motor bike. A bike performs actions such as 'Start', 'Stop' etc., and it has attributes like red color, 150 cc etc. So does an Object. Actions and attributes are represented by Methods and fields or properties respectively in programming language. An object hides the implementation details and exposes only the functionalities and parameters it requires to its client. Here also an object shares the same concept as that of a bike. While driving a motor bike, we are unaware of its implementation details such as how it is developed, internal working of gears etc.? We know only the functions or actions it can perform.
during the time of system failures. The way the roll-backed data is saved in rollback segment, the data can also be redone which is held in redo segment. A rollback segment is a portion of the database that records the actions of transactions if the transaction should be rolled back. Each database contains one or more rollback segments. Rollback segments are used to provide read consistency, to rollback transactions, and to recover the database. Types of rollbacks: - statement level rollback - rollback to a savepoint - rollback of a transaction due to user request - rollback of a transaction due to abnormal process termination - rollback of all outstanding transactions when an instance terminates abnormally - rollback of incomplete transactions during recovery. Temporary Segments: The SELECT statements need a temporary storage. When queries are fired, oracle needs area to do sorting and other operation due to which temporary storages are useful. The commands that may use temporary storage when used with SELECT are: GROUP BY, UNION, DISTINCT, etc.
Q5. What is SQL Loader? Explain the files used by SQL Loader to load file.
SQL*Loader is a bulk loader utility used for moving data from external files into the Oracle database. SQL*Loader supports various load formats, selective loading, and multi-table loads. When a control file is fed to an SQL*Loader, it writes messages to the log file, bad rows to the bad file and discarded rows to the discard file. Control file The SQL*Loader control file contains information that describes how the data will be loaded. It contains the table name, column datatypes, field delimiters, etc. controlfile.sql should be used to generate an accurate control file for a given table. Log File The log file contains information about the SQL*loader execution. It should be viewed after each SQL*Loader job is complete
Physical database structure The physical database structure comprises of datafiles, redo log files and control files Datafiles Datafiles contain database's data. The data of logical data structures such as tables and indexes is stored in datafiles of the database. One or more datafiles form a logical unit of database storage called a tablespace. Redo log files The purpose of these files is to record all changes made to data. These files protect database against failures. Control files Control files contain entries such as database name, name and location of datafiles and redo log files and time stamp of database creation
Q8. Explain the categories of oracle processes i.e. user, data writing processes, logging processes
and monitoring processes.
User process User process is used in invocation of application software. Data writing process - A database writer process is used to write buffer content into a datafile. They are specifically used to write dirty block to data files from the buffer. Logging processes - Log writer is used to write the redo log buffer from system global area to online redo log file. Only those redo entries are written hat have been copied into the buffer since the last time it wrote. Monitoring process - this can be either a system monitor process or a process monitor process. System monitor process is mainly used for crash recovery and cleaning up of temporary segments. Process monitor is used to clean all resources acquired by a failed process
SMON system monitor process is used to clean temporary segments and crash recovery of a crashed instance. PMON process monitor is used to clean all resources acquired by a failed process. DBWR- Database writer is used to write dirty block to data files from the buffer. LGWR - Log writer is used to write the redo log buffer from system global area to online redo log file. MMAN Memory manager process is used to manage the memory. ARCn - Archiver 0-9 is used for writing the online redo log files to the mentioned archive log destination after a log switch has occurred. CKPT checkpoint process using the checkpoints information signals the synchronization of all database files. Used for database consistency and faster database recovery. LCK0 -9 LOCK process is used to lock shared resources for manages the global enqueue requests and the cross-instance broadcast
+ - - Denotes positive or negative expression. They are unary operators. */- Denotes multiplication or division. They are binary operators. ||- Concatenates strings =, !=. <, >, <=, >= are all comparison operators. OR, AND, NOT are all logical operators
Example: SELECT * FROM emp WHERE job = 'CLERK' AND deptno = 10;
Example: Creating a record to store name and id of student: TYPE student_data IS RECORD ( First_name VARCHAR(20), Id NUMBER(2), ); Create a record type to hold the values declared above: Student_record student_data; To access a field: Student_record.id Assign a value: Student_record.id=1
CHECK constraint: This constraint specifies a condition for a row. Example: Create table employee ( Id, varchar(10), CONSTRAINT id CHECK (id BETWEEN 10 and 1000) ); NOT NULL constraint: This specifies that a column cannot accept NULL values. Example: Create table employee ( Id, varchar(10) NOT NULL, CONSTRAINT id CHECK (id BETWEEN 10 and 1000) ); Primary key constraint: This constraint ensures that each row is identified by a unique key. Example: Create table employee ( Id, varchar(10) NOT NULL, Roll_number INTEGER(10);
CONSTRAINT id PRIMARY KEY(Roll_number) ); Unique Constraint: This constraint ensures no columns value has repetitive values. Example: Create table employee ( Id, varchar(10) NOT NULL, Roll_number INTEGER (10); CONSTRAINT id UNIQUE (Roll_number) );
Q20. xplain the differences between char and varchar2 data types.
When a column is of type char, the memory used will not be dependent on the value. It entirely depends on the bytes defined. Example: Name CHAR(10) Each value will occupy 10 bytes of memory space even though the value may be of a smaller size. When a column is of type varchar2, the memory used entirely depends on the value of the column Example: Name VARCHAR2(10)
Each value will occupy x bytes of memory space depending on the value. To summarize, char data type is usually used when the value of fixed size is ascertained; for example Student id. On the other hand, varchar2 should be used for variable length of data; for example Name
BLOB, CLOB, NCLOB are stored internally where as BFILE is stored externally The BLOB data type stores binary large objects. The CBLOB data type stores character large objects. The NCBLOB data type stores character large objects in multibyte national character set. The BFILE data type enables access to binary file LOBs that are stored in file systems outside the Oracle database.
COMMIT - save work done SAVEPOINT - identify a point in a transaction to which you can later roll back ROLLBACK - restore database to original since the last COMMIT SET TRANSACTION - Change transaction options like isolation level and what rollback segment to use
Q28. What are difference between post database commit and post-form commit?
Post-Database-Commit It fires once during the Post and Commit Transactions process, after the database commit occurs. It fires after Oracle Forms issue the Commit to finalize the transaction. The Post-Forms-Commit It fires once during the Post and Commit Transactions process. If there are records in the form that have been marked as inserts, updates, or deletes, this trigger fires after these changes have been written to the database but before Oracle Forms issues the database Commit to finalize the transaction. If the operator or the application initiates a Commit when there are no records in the form have been marked as inserts, updates, or deletes,then Oracle Forms fires these, without posting changes to the database
Q33. Explain the guidelines for Avoiding and Handling PL/SQL Errors and Exceptions.
Guidelines for Avoiding and Handling PL/SQL Errors and Exceptions
Use both error checking and exception handling to ensure your program can handle all possibilities. Add exception handlers whenever there is any possibility of an error occurring. Add error-checking code whenever you can predict that an error might occur if your code gets bad input data. Make your programs robust enough to work even if the database is not in the state you expect. Handle named exceptions whenever possible, instead of using WHEN OTHERS in exception handlers. Test your code with different combinations of bad data to see what potential errors arise. Write out debugging information in your exception handlers. Carefully consider whether each exception handler should commit the transaction, roll it back, or let it continue
Example: int E(int x) { int F(int y) { return x + y; } return F(3); } Q37.What are SQL functions in oracle? There are two types of SQL functions in Oracle. User defined and Predefined functions. User defined functions are written by the user and predefined are the inbuilt functions in Oracle. SQL functions here are being referred to Predefined functions. These functions when called with an unexpected data type argument, Oracle attempts to convert the argument to the expected data type before performing the SQL function. MIN, MAX, ROUND etc are some functions in Oracle.
The elements within the package should be the same as they are in the declarative section of an anonymous block. The same syntax rules apply to the package header as the declarative section, except for the procedures and the functions declarations
Q41. What are the parameters to be provided while executing Export and Import commands?
The parameters that need to be provided while executing IMPORT or EXPORT commands are: The file name Write access The commit count number The nickname For example: IMPORT FROM file_1.ixf OF IXF ALLOW WRITE ACCESS COMMITCOUNT 20 INSERT INTO NICKNAME_1;
Q42. What is the difference between the SQL*Loader and IMPORT utilities?
SQL*Loader is a bulk loader utility used for moving data from external files into the Oracle database. SQL*Loader supports various load formats, selective loading, and multi-table loads. Oracle's export (exp) and import (imp) utilities are used to perform logical database backup and recovery. When exporting, database objects are dumped to a binary file which can then be imported into another Oracle database
Q44. What are the different operators used in building sub queries?
Following operators can be used in building sub queries: IN: Allows multiple values to be checked. EXIST: Checks if a value exists. There are other logical operators like AND, OR and comparison operators like =, <, > can also be used. Example: Select emp_id, emp_name from employee Where emp_id IN (select emp_id FROM salary);
Caution should be taken with simple sub-query, especially when a normal value operator is used on the results of a sub-query, only one field must be returned If you want to check for the existence of a single value within a set of other values, use the IN keyword as an operator upon the result set from a sub-query.
Example of a Sub-Query: SELECT name FROM students WHERE stud_id = (SELECT stud_id FROM class WHERE last_name='abc' AND first_name='xyz');
The following example will show what a DROP does: SQL> DROP TABLE emp; Table dropped
Q51. Explain the use of Alter Table command. Explain with an example.
ALTER table command is used to modify a tables column attributes, renaming a table or column etc. Example: 1. 2. Add column to an existing table ALTER table student ADD COLUMN department varhchar(100); Rename a table ALTER table student RENAME TO studentdata;
create table test of x_type; create or replace type atype as object ( a varchar2(30), b date ) Create table p of atype; Index Organized Tables Index Organized Tables have their primary key and non-key column data stored within the same B-Tree structure. The data is stored within the primary key index. Use: IOTs make accessing data via the primary key quicker as the key and the data reside in the same structure. Since there is no need to read an index, the table data is read in a separate structure. Less duplication of the key columns in an index and table mean low storage requirements. Hash clustered tables Hash clusters provide a good facility for storage and retrieval. In the case of a heap table, the rows are not sorted in a user-controlled manner. Oracle hash cluster tables can improve random row access speed by foour times as the hash can get the row location far faster than index access. Multiple table hash clusters store logically-related rows on a single data block due to which you can access a whole unit of data in a single physical I/O. Nested tables Nested table can be used to link the subordinate data items to the base table using the object ID (OID). Oracle objects can be directly referenced by using pointers as opposed joining relational. Objects in standard relational databases need to be reassembled every time it is used. Index cluster tables An index cluster uses an index to maintain row sequence. A table cluster is a group of tables that share the same data blocks, since they share common columns and are often used together. All rows for each table are stored in the same data blocks, When you create cluster tables are created.
The cluster key value is the value of the cluster key columns for a particular row. Index cluster tables can be either multi-table or single-table
Row level triggers Statement level triggers BEFORE and AFTER triggers
Fired when a DML operation is performed They manipulate data stored in Oracle tables They can cause other database triggers to fire. They can be fired from any session executing the triggering DML statements.
Fired in response to any event that takes place while working with the forms. They manipulate data in Oracle tables as well as variables in forms. They cannot cause other form triggers to fire, but can fire other database triggers. They can be fired only from the form that define the trigger