Interview Question
Interview Question
Inheritance
Abstraction
Encapsulation
Polymorphism
SQL Server
What is normalization?
Well a relational database is basically composed of tables that contain related data. So the Process of
organizing this data into tables is actually referred to as normalization.
Its nothing but a set of T-SQL statements combined to perform a single task of several tasks. Its basically
like a Macro so when you invoke the Stored procedure, you actually run a set of statements.
sp_helpdb , sp_who2, sp_renamedb are a set of system defined stored procedures. We can also have user
defined stored procedures which can be called in similar way.
What is a trigger?
Triggers are basically used to implement business rules. Triggers is also similar to stored procedures. The
difference is that it can be activated when data is added or edited or deleted from a table in a database.
1
What is a view?
If we have several tables in a db and we want to view only specific columns from specific tables we can go
for views. It would also suffice the needs of security some times allowing specfic users to see only specific
columns based on the permission that we can configure on the view. Views also reduce the effort that is
required for writing queries to access specific columns every time.
What is an Index?
When queries are run against a db, an index on that db basically helps in the way the data is sorted to
process the query for faster and data retrievals are much faster when we have an index.
There are basically two types of indexes that we use with the SQL Server. Clustered and the Non-Clustered.
The difference is that, Clustered index is unique for any given table and we can have only one clustered
index on a table. The leaf level of a clustered index is the actual data and the data is resorted in case of
clustered index. Whereas in case of non-clustered index the leaf level is actually a pointer to the data in
rows so we can have as many non-clustered indexes as we can on the db.
What are cursors?
Well cursors help us to do an operation on a set of data that we retreive by commands such as Select
columns from table. For example : If we have duplicate records in a table we can remove it by declaring a
cursor which would check the records during retreival one by one and remove rows which have duplicate
values.
This command is basically used when we do a large processing of data. If we do a large amount of deletions
any modification or Bulk Copy into the tables, we need to basically update the indexes to take these
changes into account. UPDATE_STATISTICS updates the indexes on these tables accordingly.
SQL Server runs on port 1433 but we can also change it for better security.
From the Network Utility TCP/IP properties –> Port number.both on client and the server.
Can you tell me the difference between DELETE & TRUNCATE commands?
Delete command removes the rows from a table based on the condition that we provide with a WHERE
clause. Truncate will actually remove all the rows from a table and there will be no data in the table after we
run the truncate command.
No. We cannot use Truncate command on a table with Foreign Key because of referential integrity.
DBCC stands for database consistency checker. We use these commands to check the consistency of the
2
databases, i.e., maintenance, validation task and status checks.
DBCC CHECKDB - Ensures that tables in the db and the indexes are correctly linked.and DBCC
CHECKALLOC - To check that all pages in a db are correctly allocated. DBCC SQLPERF - It gives report on
current usage of transaction log in percentage. DBCC CHECKFILEGROUP - Checks all tables file group for
any damage.
In such cases we can first bring to db to single user using sp_dboptions and then we can rename that db
and then we can rerun the sp_dboptions command to remove the single user mode.
Having Clause is basically used only with the GROUP BY function in a query. WHERE Clause is applied to
each row before they are part of the GROUP BY function in a query.
Collation is basically the sort order. There are three types of sort order Dictionary case sensitive, Dictonary -
case insensitive and Binary.
Join actually puts data from two or more tables into a single result set.
Can you explain the types of Joins that we can have with Sql Server?
There are three types of joins: Inner Join, Outer Join, Cross Join
SQL Profiler utility allows us to basically track connections to the SQL Server and also determine activities
such as which SQL Scripts are running, failed jobs etc..
Linked Servers is a concept in SQL Server by which we can add other SQL Server to a Group and query
both the SQL Server dbs using T-SQL Statements.
Can you link only other SQL Servers or any database servers such as Oracle?
We can link any server provided we have the OLE-DB provider from Microsoft to allow a link. For Oracle we
have a OLE-DB provider for oracle that microsoft provides to add it as a linked server to the sql server
group.
sp_addlinkedserver, sp_addlinkedsrvlogin
What are the OS services that the SQL Server installation adds?
3
MS SQL SERVER SERVICE, SQL AGENT SERVICE, DTC (Distribution transac co-ordinator)
SQL SERVER - is for running the databases SQL AGENT - is for automation such as Jobs, DB
Maintanance, Backups DTC - Is for linking and connecting to other SQL Servers
How do you troubleshoot SQL Server if its running very slow?
First check the processor and memory usage to see that processor is not above 80% utilization and memory
not above 40-45% utilization then check the disk utilization using Performance Monitor, Secondly, use SQL
Profiler to check for the users and current SQL activities and jobs running which might be a problem. Third
would be to run UPDATE_STATISTICS command to update the indexes
Lets say due to N/W or Security issues client is not able to connect to server or vice versa. How do
you troubleshoot?
First I will look to ensure that port settings are proper on server and client Network utility for connections.
ODBC is properly configured at client end for connection ——Makepipe & readpipe are utilities to check for
connection. Makepipe is run on Server and readpipe on client to check for any connection issues.
Where do you think the users names and passwords will be stored in sql server?
Logshipping is a new feature of SQL Server 2000. We should have two SQL Server - Enterprise Editions.
From Enterprise Manager we can configure the logshipping. In logshipping the transactional log file from one
server is automatically updated into the backup database on the other server. If one server fails, the other
server will have the same db and we can use this as the DR (disaster recovery) plan.
Let us say the SQL Server crashed and you are rebuilding the databases including the master
database what procedure to you follow?
For restoring the master db we have to stop the SQL Server first and then from command line we can type
SQLSERVER .m which will basically bring it into the maintenance mode after which we can restore the
master db.
Let us say master db itself has no backup. Now you have to rebuild the db so what kind of action do
you take?
BulkCopy is a tool used to copy huge amount of data from tables and views. But it won’t copy the structures
of the same.
What should we do to copy the tables, schema and views from one SQL Server to another?
4
1.What’s the implicit name of the parameter that gets passed into the class’ set method?
Value and its data type depend on whatever variable we’re changing.
Place a colon and then the name of the base class. Notice that it’s double colon in C++.
Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they
are.
It’s available to derived classes and classes within the same Assembly (and naturally from the base class it’s
declared in).
7.C# provides a default constructor for me. I write a constructor that takes a string as a parameter,
but want to keep the no parameter one. How many constructors should I write?
Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write
one yourself, even if there’s no implementation in it.
System. Object.
When overriding, you change the method behavior for a derived class. Overloading simply involves having a
method with the same name within the class.
11.Can you declare the override method static while the original method is non-static?
No, you can’t, the signature of the virtual method must remain the same, only the keyword virtual is changed
to keyword override.
No, moreover, you cannot access private methods in inherited classes, have to be protected in the base
class to allow any sort of access.
13.Can you prevent your class from being inherited and becoming a base class for some other
5
classes?
Yes, that’s what keyword sealed in the class definition is for. The developer trying to derive from your class
will get a message: cannot inherit from Sealed class WhateverBaseClassName. It’s the same concept as
final class in Java.
14.Can you allow class to be inherited, but prevent the method from being over-ridden?
Yes, just leave the class public and make the method sealed.
A class that cannot be instantiated. A concept in C++ known as pure virtual method. A class that must be
inherited and have the methods over-ridden. Essentially, it’s a blueprint for a class without any
implementation.
16.When do you absolutely have to declare a class as abstract (as opposed to free-willed educated
choice or decision based on UML diagram)?
When at least one of the methods in the class is abstract. When the class itself is inherited from an abstract
class, but not all base abstract methods have been over-ridden.
It’s an abstract class with public abstract methods all of which must be implemented in the inherited classes.
18.Why can’t you specify the accessibility modifier for methods inside the interface?
They all must be public. Therefore, to prevent you from getting the false impression that you have any
freedom of choice, you are not allowed to specify any accessibility, its public by default.
It’s up to you to implement the method inside your own class, so implementation is left entirely up to you.
This might cause a problem on a higher-level scale if similarly named methods from different interfaces
expect different data, but as far as compiler cares you’re okay.
In the interface all methods must be abstract; in the abstract class some methods can be concrete. In the
interface no accessibility modifiers are allowed, which is ok in abstract classes.
Different parameter data types, different number of parameters, different order of parameters.
23.If a base class has a bunch of overloaded constructors, and an inherited class has another bunch
of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base
constructor?
Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the
overloaded constructor definition inside the inherited class.
6
24.What’s the difference between Systems? String and System.StringBuilder classes?
System. String is immutable; System.StringBuilder was designed with the purpose of having a mutable
string where a variety of operations can be performed.
String Builder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are
immutable, so each time it’s being operated on, a new instance is created.
No.
The first one performs a deep copy of the array, the second one is shallow.
28.How can you sort the elements of the array in descending order?
29.What’s the .NET data type that allows the retrieval of data by a unique key?
Hash Table.
31.Will finally block get executed if the exception had not occurred?
Yes.
32. What’s the C# equivalent of C++ catch (…), which was a catch-all statement for any possible
exception?
A catch block that catches the exception of type System. Exception. You can also omit the parameter data
type in this case and just write catch {}.
No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and
then whatever follows the finally block.
Well, if at that point you know that an error has occurred, then why not write the proper code to handle that
error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies
some design flaws in the project.
35.What’s a delegate?
A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.
36.What’s a multicast delegate?
It’s a delegate that points to and eventually fires off several methods.
7
37.How’s the DLL Hell problem solved in .NET?
Assembly versioning allows the application to specify not only the library it needs to run (which was available
under Win32), but also the version of the assembly.
When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application
separately from the localized modules, the localized assemblies that modify the core application are called
satellite assemblies.
42.How do you generate documentation from the C# file commented properly with a command-line
compiler?
43.What’s the difference between <c> and <code> XML documentation tag?
CorDBG – command-line debugger, and DbgCLR – graphic debugger. Visual Studio .NET uses the
DbgCLR. To use CorDbg, you must compile the original C# file using the /debug switch.
It points to the object that’s pointed to by this reference. Object’s instance data is shown.
In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the
condition is false. The program proceeds without any interruption if the condition is true.
48.What’s the difference between the Debug class and Trace class? Documentation looks the same.
Use Debug class for debug builds, use Trace class for both debug and release builds.
The tracing dumps can be quite verbose and for some applications that are constantly running you run the
8
risk of overloading the machine and the hard drive there. Five levels range from none to Verbose, allowing
fine-tuning the tracing activities.
To the Console or a text file depending on the parameter passed to the constructor.
51.How do you debug an ASP.NET Web application?
52.What are three test cases you should go through in unit testing?
Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper
handling), exception test cases (exceptions are thrown and caught properly).
Yes, if you are debugging via Visual Studio.NET, just go to immediate window.
Presentation (UI), business (logic and underlying code) and data (from storage or other sources).
SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from
Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and
Informix, but it’s a .NET layer on top of OLE layer, so not the fastest thing in the world. ODBC.NET is a
deprecated layer provided for backward compatibility to ODBC engines.
It returns a read-only dataset from the data source when the command is executed.
57.What is the wildcard character in SQL? Let’s say you want to query database with LIKE for all
employees whose name starts with La.
The wildcard character is %, the proper query with LIKE would involve ‘La%’.
Transaction must be Atomic (it is one unit of work and does not dependent on previous and following
transactions), Consistent (data is either committed or roll back, no “in-between” case where something has
been updated and something hasn’t), Isolated (no transaction sees the intermediate results of the current
transaction), Durable (the values persist if the data had been committed even if the system crashes right
after).
Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server
username and passwords).
Windows Authentication is trusted because the username and password are checked with the Active
Directory; the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in
9
the transaction.
62.What does the parameter Initial Catalog define inside Connection String?
Microsoft. Access.
Multiple processes must agree that they will share the same connection, where every parameter is the
same, including the security settings.
- No.
4. If I return out of a try/finally in C#, does the code in the finally-clause run?
- Yes. The code in the finally always runs. If you return out of the try block, or even if you do a “goto” out of
the try, the finally block always runs:
using System;
class main
{
public static void Main()
{
try
{
Console.WriteLine(\"In Try block\");
return;
}
finally
{
Console.WriteLine(\"In Finally block\");
}
}
10
}
Both “In Try block” and “In Finally block” will be displayed. Whether the return is in the try block or after the
try-finally block, performance is not affected either way. The compiler treats it as if the return were outside
the try block anyway. If it’s a return without an expression (as it is above), the IL emitted is identical whether
the return is inside or outside of the try. If the return has an expression, there’s an extra store/load of the
value of the expression (since it has to be computed within the try block).
5.I was trying to use an “out int” parameter in one of my functions. How should I declare the variable
that I am passing to it?
- You should declare the variable as an int, but when you pass it in you must specify it as ‘out’, like the
following: int i; foo(out i); where foo is declared as follows: [return-type] foo(out int o) { }
- In the past, you had to call .ToString() on the strings when using the == or != operators to compare the
strings’ values. That will still work, but the C# compiler now automatically compares the values instead of the
references when the == or != operators are used on string types. If you actually do want to compare
references, it can be done as follows: if ((object) str1 == (object) str2) { … } Here’s an example showing how
string compares work:
using System;
public class StringTest
{
public static void Main(string[] args)
{
Object nullObj = null; Object realObj = new StringTest();
int i = 10;
Console.WriteLine(\"Null Object is [\" + nullObj + \"]\n\"
+ \"Real Object is [\" + realObj + \"]\n\"
+ \"i is [\" + i + \"]\n\");
// Show string equality operators
string str1 = \"foo\";
string str2 = \"bar\";
string str3 = \"bar\";
Console.WriteLine(\"{0} == {1} ? {2}\", str1, str2, str1 == str2 );
Console.WriteLine(\"{0} == {1} ? {2}\", str2, str3, str2 == str3 );
}
}
Output:
Null Object is []
Real Object is [StringTest]
i is [10]
foo == bar ? False
bar == bar ? True
7.How do you specify a custom attribute for the entire assembly (rather than for a class)?
- Global attributes must appear after any top-level using clauses and before the first type or namespace
declarations. An example of this is as follows:
using System;
[assembly : MyAttributeClass] class X {}
Note that in an IDE-created project, by convention, these attributes are placed in AssemblyInfo.cs.
11
8.How do you mark a method obsolete? -
or
[Obsolete(\"This is a message describing why this method is obsolete\")] public int Foo() {...}
- You want the lock statement, which is the same as Monitor Enter/Exit:
lock(obj) { // code }
translates to
try {
CriticalSection.Enter(obj);
// code
}
finally
{
CriticalSection.Exit(obj);
}
10. How do you directly call a native function exported from a DLL?
using System.Runtime.InteropServices; \
class C
{
[DllImport(\"user32.dll\")]
public static extern int MessageBoxA(int h, string m, string c, int type);
public static int Main()
{
return MessageBoxA(0, \"Hello World!\", \"Caption\", 0);
}
}
This example shows the minimum requirements for declaring a C# method that is implemented in a native
DLL. The method C.MessageBoxA() is declared with the static and external modifiers, and has the DllImport
attribute, which tells the compiler that the implementation comes from the user32.dll, using the default name
of MessageBoxA. For more information, look at the Platform Invoke tutorial in the documentation.
- You must use the Missing class and pass Missing.Value (in System.Reflection) for any values that have
optional parameters.
1.Are private class-level variables inherited?
- Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited.
12
- All methods marked with the DllImport attribute must be marked as public static extern.
3. Why does my Windows application pop up a console window every time I run it?
- Make sure that the target type set in the project properties setting is set to Windows Application, and not
Console Application. If you’re using the command line, compile with /target:winexe, not /target:exe.
4.Why do I get an error (CS1006) when trying to declare a method without specifying a return type?
- If you leave off the return type on a method declaration, the compiler thinks you are trying to declare a
constructor. So if you are trying to declare a method that returns nothing, use void. The following is an
example: // This results in a CS1006 error public static staticMethod (main Static obj) // This will work as
wanted public static void static Method (main Static obj)
5.Why do I get a syntax error when trying to declare a variable called checked?
- Some security exceptions are thrown if you are working on a network share. There are some parts of the
frameworks that will not run if being run off a share (roaming profile, mapped drives, etc.). To see if this is
what’s happening, just move the executable over to your local drive and see if it runs without the exceptions.
One of the common exceptions thrown under these conditions is System.Security.SecurityException. To get
around this, you can change your security policy for the intranet zone, code group 1.2, (the zone that
running off shared folders falls into) by using the caspol.exe tool.
7.Why do I get a CS5001: does not have an entry point defined error when compiling?
- The most common problem is that you used a lowercase ‘m’ when defining the Main method. The correct
way to implement the entry point is as follows: class test { static void Main(string[] args) {} }
8.What optimizations does the C# compiler perform when you use the /optimize+ compiler option?
- The following is a response from a developer on the C# compiler team: We get rid of unused locals (i.e.,
locals that are never read, even if assigned). We get rid of unreachable code. We get rid of try-catch with an
empty try. We get rid of try-finally with an empty try. We get rid of try-finally with an empty finally. We
optimize branches over branches: gotoif A, lab1 goto lab2: lab1: turns into: gotoif !A, lab2 lab1: We optimize
branches to ret, branches to next instruction, and branches to branches.
9.What is the syntax for calling an overloaded constructor within a constructor (this() and
constructorname() does not compile)?
The syntax for calling another constructor is as follows: class B { B(int i) { } } class C : B { C() : base(5) // call
base constructor B(5) { } C(int i) : this() // call C() { } public static void Main() {} }
- From language spec: The list of similarities between classes and structs is as follows. Longstructs can
implement interfaces and can have the same kinds of members as classes. Structs differ from classes in
several important ways; however, structs are value types rather than reference types, and inheritance is not
supported for structs. Struct values are stored on the stack or in-line. Careful programmers can sometimes
13
enhance performance through judicious use of structs. For example, the use of a struct rather than a class
for a Point can make a large difference in the number of memory allocations performed at runtime. The
program below creates and initializes an array of 100 points. With Point implemented as a class, 101
separate objects are instantiated-one for the array and one each for the 100 elements.
- C# does not support an explicit fall through for case blocks. The following code is not legal and will not
compile in C#:
switch(x)
{
case 0: // do something
case 1: // do something as continuation of case 0
default: // do something in common with
//0, 1 and everything else
break;
}
To achieve the same effect in C#, the code must be modified as shown below (notice how the control flows
are explicit):
class Test
{
public static void Main() {
int x = 3;
switch(x)
{
case 0: // do something
goto case 1;
case 1: // do something in common with 0
goto default;
default: // do something in common with 0, 1, and anything else
break;
}
}
}
- Yes. The .NET class libraries provide support for regular expressions. Look at the
System.Text.RegularExpressions namespace.
- Yes:
using System;
using System.Threading;
class ThreadTest
{
public void runme()
{
Console.WriteLine(\"Runme Called\");
}
public static void Main(String[] args)
{
ThreadTest b = new ThreadTest();
14
Thread t = new Thread(new ThreadStart(b.runme));
t.Start();
}
}
- Yes, you can use System.Environment.Exit(int exitCode) to exit the application or Application.Exit() if it’s a
Windows Forms app.
- Yes. Set all references to null and then call System.GC.Collect(). If you need to have some objects
destructed, and System.GC.Collect() doesn’t seem to be doing it for you, you can force finalizers to be run
by setting all the references to the object to null and then calling System.GC.RunFinalizers().
17. Is there a way of specifying which block or loop to break out of when working with nested loops?
using System;
class BreakExample
{
public static void Main(String[] args) {
for(int i=0; i<3; i++)
{
Console.WriteLine(\"Pass {0}: \", i);
for( int j=0 ; j<100 ; j++ )
{
if ( j == 10)
goto done;
Console.WriteLine(\"{0} \", j);
}
Console.WriteLine(\"This will not print\");
}
done:
Console.WriteLine(\"Loops complete.\");
}
}
18.Is it possible to restrict the scope of a field/method of a class to the classes in the same
namespace?
- There is no way to restrict to a namespace. Namespaces are never units of protection. But if you’re using
assemblies, you can use the ‘internal’ access modifier to restrict access to only within the assembly.
15
= Equal
<> or != Not equal
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
BETWEEN Between an inclusive range
LIKE Search for a pattern
4. The SELECT INTO Statement is most often used to create backup copies of tables or for archiving
records.
9. The IN operator may be used if you know the exact value you want to return for at least one of the
columns.
SELECT column_name FROM table_name WHERE column_name BETWEEN value1 AND value2 The
values can be numbers, text, or dates.
16
11. What is the use of CASCADE CONSTRAINTS?
When this clause is used with the DROP command, a parent table can be dropped even when a child table
exists.
DROP TABLE &TABLE NAME; Variable names should start with an alphabet. Here the table name starts
with an '&' symbol.
13. Which system tables contain information on privileges granted and privileges obtained?
USER_TAB_PRIVS_MADE, USER_TAB_PRIVS_RECD
14. Which system table contains information on constraints on all the tables created?obtained?
USER_CONSTRAINTS.
16. State true or false. !=, <>, ^= all denote the same operation?
True.
17. State true or false. EXISTS, SOME, ANY are operators in SQL?
True.
18. What will be the output of the following query?
SELECT REPLACE(TRANSLATE(LTRIM(RTRIM('!! ATHEN !!','!'), '!'), 'AN', '**'),'*','TROUBLE') FROM
DUAL;?
19. What does the following query do?
SELECT SAL + NVL(COMM,0) FROM EMP;?
This displays the total salary of all employees. The null values in the commission column will be replaced by
0 and added to salary.
20. What is the advantage of specifying WITH GRANT OPTION in the GRANT command?
The privilege receiver can further grant the privileges he/she has obtained from the owner to any other user.
START or @.
22. What is the value of comm and sal after executing the following query if the initial value of ‘sal’ is
10000
UPDATE EMP SET SAL = SAL + 1000, COMM = SAL*0.1;?
23. Which command displays the SQL command in the SQL buffer, and then executes it?
RUN.
24. What command is used to get back the privileges offered by the GRANT command?
REVOKE.
17
25. What will be the output of the following query? SELECT
DECODE(TRANSLATE('A','1234567890','1111111111'), '1','YES', 'NO' );? NO.
Explanation : The query checks whether a given string is a numerical digit.
26. Which date function is used to find the difference between two dates?
MONTHS_BETWEEN.
LIKE operator.
28. What is the use of the DROP option in the ALTER TABLE command?
IS NULL operator.
30. What are the privileges that can be granted on a table by a user to others?
32. Which is the subset of SQL commands used to manipulate Oracle Database structures, including
tables?
DESC has two purposes. It is used to describe a schema as well as to retrieve rows from table in
descending order.
Explanation :
The query SELECT * FROM EMP ORDER BY ENAME DESC will display the output sorted on ENAME in
descending order.
34. What command is used to create a table by copying the structure of another table?
18
_ for single character substitution and % for multi-character substitution.
38. What is the parameter substitution symbol used with INSERT INTO command?
&
SQL Injection is when form data contains an SQL escape sequence and injects a new SQL query to be run.
40. What is difference between TRUNCATE & DELETE
TRUNCATE commits after deleting entire table i.e., cannot be rolled back. Database triggers do not fire on
TRUNCATE
DELETE allows the filtered deletion. Deleted records can be rolled back or committed. Database triggers fire
on DELETE.
Join is a query, which retrieves related columns or rows from multiple tables.
Self Join - Joining the table with itself.
Equi Join - Joining two tables by equating two common columns.
Non-Equi Join - Joining two tables by equating two common columns.
Outer Join - Joining two tables in such a way that query can also retrieve rows that do not have
corresponding join value in the other table.
42. What is the sub-query?
Sub-query is a query whose return values are used in filtering conditions of the main query.
INTERSECT - returns all distinct rows selected by both queries. MINUS - returns all distinct rows selected
by the first query but not by the second. UNION - returns all distinct rows selected by either query UNION
ALL - returns all rows selected by either query, including all duplicates.
ROWID is a pseudo column attached to each row of a table. It is 18 characters long, blockno, rownumber
are the components of ROWID.
19
Using ROWID.
CONSTRAINTS
49. What is an integrity constraint?
Integrity constraint is a rule that restricts values to a column in a table.
Maintaining data integrity through a set of rules that restrict the values of one or more columns of the tables
based on the values of primary key or unique key of the referenced table.
SAVEPOINTS are used to subdivide a transaction into smaller parts. It enables rolling back part of a
transaction. Maximum of five save points are allowed.
When ON DELETE CASCADE is specified Oracle maintains referential integrity by automatically removing
dependent foreign key values if a referenced primary or unique key value is removed.
54. What is difference between CHAR and VARCHAR2? What is the maximum SIZE allowed for each
type?
56. What are the pre-requisites to modify datatype of a column and to add a column with NOT NULL
constraint?
The integrity constraints can be enabled or disabled by ALTER TABLE ENABLE CONSTRAINT / DISABLE
CONSTRAINT.
59. If unique key constraint on DATE column is created, will it validate the rows that are inserted with
SYSDATE?
It won't, Because SYSDATE format contains time attached with it.
Database link is a named path through which a remote database can be accessed.
20
60. How to access the current value and next value from a sequence? Is it possible to access the
current value in a session before accessing next value?
Sequence name CURRVAL, sequence name NEXTVAL. It is not possible. Only if you access next value in
the session, current value can be accessed.
CYCLE specifies that the sequence continue to generate values after reaching either maximum or minimum
value. After pan-ascending sequence reaches its maximum value, it generates its minimum value. After a
descending sequence reaches its minimum, it generates its maximum.
NO CYCLE specifies that the sequence cannot generate more values after reaching its maximum or
minimum value.
A View can be updated/deleted/inserted if it has only one base table if the view is based on columns from
one or more tables then insert, update and delete is not possible.
63. If a view on a single base table is manipulated will the changes be reflected on the base table?
If changes are made to the tables and these tables are the base tables of a view, then the changes will be
reference on the view.
64. Which of the following statements is true about implicit cursors?
1. Implicit cursors are used for SQL statements that are not named.
2. Developers should use implicit cursors with great care.
3. Implicit cursors are used in cursor for loops to handle data processing.
4. Implicit cursors are no longer a feature in Oracle.
1. %found
2. %too_many_rows
3. %notfound
4. %rowcount
5. %rowtype
21
68. If left out, which of the following would cause an infinite loop to occur in a simple loop?
1. LOOP
2. END LOOP
3. IF-THEN
4. EXIT
69. 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.
1. open
2. fetch
3. parse
4. None, cursor for loops handle cursor opening implicitly.
71. What happens when rows are found using a FETCH statement
The trigger code should only execute when the column, COST_PER_TICKET, is greater than $3. Which
trigger information will you add?
74. 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
77. 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
23
41. v_budget studio.yearly_budget%TYPE;
42. BEGIN
43. v_budget := get_budget(11);
44. IF v_budget < 30000
45. THEN
46. set_budget(11,30000000);
47. END IF;
48. END;
You are about to add an argument to CALCULATE_BUDGET. What effect will
this have?
1. RAISE_ERROR
2. SQLERRM
3. RAISE_APPLICATION_ERROR
4. RAISE_SERVER_ERROR
82. The CHECK_THEATER trigger of the THEATER table has been disabled.
Which command can you issue to enable this trigger?
85. Under which circumstance must you recompile the package body
after recompiling the package specification?
87. Which Oracle supplied package can you use to output values
and messages from database triggers, stored procedures and functions
within SQL*Plus?
1. Any DML statements issued by the construct are still pending and can be committed or rolled back.
2. Any DML statements issued by the construct are committed
3. Unless a GOTO statement is used to continue processing within the BEGIN section,the construct terminates.
4. The construct rolls back any DML statements issued and returns the unhandled
exception to the calling environment.
1. DBMS_DDL
2. DBMS_DML
3. DBMS_SYN
4. DBMS_SQL
Method 1:
Will give you a zero if it is a number or greater than zero if not numeric
(actually gives the count of non numeric characters)
Method 2:
select instr(translate('wwww','abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ','XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXX'),'X') FROM dual;
select * from (select rownum a, CLASS_CODE,CLASS_DESC from clm) where a > ( select (max(rownum)-
10) from clm) Here N = 10
The following query has a Problem of performance in the execution of the following
query where the table ter.ter_master have 22231 records. So the results are obtained
after hours.
What are steps required tuning this query to improve its performance?
SELECT a.*
FROM ter.ter_master a
WHERE NOT EXISTS (SELECT b.repno FROM ermast b
WHERE a.repno=b.repno) AND
(a.brepno = 'ALL' or a.repno > a.brepno)
26
ORDER BY a.repno;
93 What is the difference between Truncate and Delete interms of Referential Integrity?
DELETE removes one or more records in a table, checking referential Constraints (to see if there are
dependent child records) and firing any DELETE triggers. In the order you are deleting (child first then
parent) There will be no problems.
TRUNCATE removes ALL records in a table. It does not execute any triggers. Also, it
only checks for the existence (and status) of another foreign key Pointing to the
table. If one exists and is enabled, then you will get The following error. This
is true even if you do the child tables first.
ORA-02266: unique/primary keys in table referenced by enabled foreign keys
You should disable the foreign key constraints in the child tables before issuing
the TRUNCATE command, then re-enable them afterwards.
CLIENT/SERVER
Preemptive refers to the fact that each task is alloted fixed time slots and at the end of that time slot the next
task is started.
97. In a client server environment, what would be the major work that the client deals with ?
The client deals with the user interface part of the system.
To reduce the network traffic and for application sharing and implementing business rules.
Applications that have outgrown their environment are re-engineered to run in a larger environment. This is
upsizing.
With rightsizing, one would move applications to the most appropriate server platforms.
An event trigger, a segment of code which is associated with each event and is fired
when the event occurs.
27
When a stored procedure is called, only the procedure call is sent to the server and
not the statements that the procedure contains.
104. What are the types of processes that a server runs ?
An integrity constraint allows the definition of certain restrictions, at the table level, on the data that is
entered into a table.
Database triggers can be used to enforce business rules, to maintain derived values
and perform value-based auditing.
110. Why is it better to use an integrity constraint to validate data in a table than to use a stored
procedure ?
A Client,
A Server and
A Network/Communication software.
Flexibility of the system, scalability, cost saving, centralised control and implementation of business rules,
increase of developers productivity, portability, improved network and resource utilization.
Heterogeneity of the system results in reduced reliablity. May not be suitable for all applications. Managing and
tuning networks becomes difficult.
Star,
Bus,
Ring.
116. In a Client/Server context, what does API (Application Programming Interface) refer to ?
An API, in a Client/Server context, is a specification of a set of functions for communication between the client
and the server.
The application can be connected to any back end server that is supported by the API.
The application cannot use any special features of the backend server.
Because an event driven program is always waiting for something to happen before processing.
1. System Events.
2. Control Events
3. User Events
4. Other Events.
121. What is the difference between file server and a database server ?
A file server just transfers all the data requested by all its client and the client processes the data while a
database server runs the query and sends only the query output.
Inheritance is a method by which properties and methods of an existing object are automatically passed to any
object derived from it.
29
The ODBC Manager manages all the data sources that exists in the system.
The ODBC Driver allows the developer to talk to the back end database.
The name of the DBMS, the location of the source and the database dependent
information.
ODBC uses the description of the datasource available in the ODBC.INI file to load
the required drivers to access that particular back end database.
Class Questions
1. What’s the implicit name of the parameter that gets passed into the set method/property of a
class?
Value. The data type of the value parameter is defined by whatever data type the property is declared as.
2. What does the keyword “virtual” declare for a method or property?
The method or property can be overridden.
3. How is method overriding different from method overloading?
When overriding a method, you change the behavior of the method for the derived class. Overloading a
method simply involves having another method with the same name within the class.
4. Can you declare an override method to be static if the original method is not static?
No. The signature of the virtual method must remain the same. (Note: Only the keyword virtual is changed
to keyword override)
5. What are the different ways a method can be overloaded?
Different parameter data types, different number of parameters, different order of parameters.
6. If a base class has a number of overloaded constructors, and an inheriting class has a number
of overloaded constructors; can you enforce a call from an inherited constructor to a specific base
constructor?
Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the
overloaded constructor definition inside the inherited class.
1. What’s a delegate?
A delegate object encapsulates a reference to a method.
2. What’s a multicast delegate?
A delegate that has multiple handlers assigned to it. Each assigned handler (method) is called.
1. Is XML case-sensitive?
Yes.
2. What’s the difference between // comments, /* */ comments and /// comments?
Single-line comments, multi-line comments, and XML documentation comments.
3. How do you generate documentation from the C# file commented properly with a command-line
compiler?
Compile it with the /doc switch.
32
Debugging and Testing Questions
33
4. Durable - the values persist if the data had been committed even if the system crashes right after.
5. What connections does Microsoft SQL Server support?
Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server
username and password).
6. Between Windows Authentication and SQL Server Authentication, which one is trusted and
which one is untrusted?
Windows Authentication is trusted because the username and password are checked with the Active
Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in
the transaction.
7. What does the Initial Catalog parameter define in the connection string?
The database name to connect to.
8. What does the Dispose method do with the connection object?
Deletes it from the memory.
To Do: answer better. The current answer is not entirely correct.
9. What is a pre-requisite for connection pooling?
Multiple processes must agree that they will share the same connection, where every parameter is the
same, including the security settings. The connection string must be identical.
Assembly Questions
34