0% found this document useful (0 votes)
79 views34 pages

Interview Question

The document discusses various concepts related to object-oriented programming and SQL Server including inheritance, abstraction, encapsulation, polymorphism, normalization, stored procedures, triggers, views, indexes, cursors, database consistency checks, joins, linked servers, authentication modes, and log shipping.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views34 pages

Interview Question

The document discusses various concepts related to object-oriented programming and SQL Server including inheritance, abstraction, encapsulation, polymorphism, normalization, stored procedures, triggers, views, indexes, cursors, database consistency checks, joins, linked servers, authentication modes, and log shipping.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 34

 What is the syntax to derive from a class in C#?

derived : clone and base class


 Can you prevent your class from being derived from by another class? Yes, key word sealed
 Can you allow a class to be derived from, but prevent a method from being over-ridden? Yes, make
class leave public and make method is sealed
 What’s an abstract class?
o An abstract class is a class that must be inherited and have the methods overridden.  
o An abstract class is essentially a blueprint for a class without any implementation. 
 When do you absolutely have to declare a class as abstract?
o When at least one of the methods in the class is abstract
 What is an interface?
o Is an abstract class with public method
 What are the differences between an abstract class and an interface?
o In interface all method must be abstract, and in the abstract some method can concrete
 Why can’t you specify the accessibility modifier for methods inside the interface? It is default is
public, if other it have no meaning of interface
 Can you implement multiple interfaces? Yes
 What happens if you implement multiple interfaces and they have conflicting method names?
o
 What is the difference between a Struct and a Class?
o Can not inheritance from another struct or class
o It less expensive
 How would you describe encapsulation in OO?

 What is the Singleton Design Pattern? What does volatile provide?
 When would you want to use the composite pattern?
 What is the square root of 2??
 Who is buried in Grant's tomb?

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.

What is a Stored Procedure?

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.

Can you give an example of Stored Procedure?

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.

What are the types of indexes available with SQL Server?

There are basically two types of indexes that we use with the SQL Server. Clustered and the Non-Clustered.

What is the basic difference between clustered and a non-clustered index?

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.

When do we use the UPDATE_STATISTICS command?

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.

Which TCP/IP port does SQL Server run on?

SQL Server runs on port 1433 but we can also change it for better security.

From where can you change the default port?

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.

Can we use Truncate command on a table which is referenced by FOREIGN KEY?

No. We cannot use Truncate command on a table with Foreign Key because of referential integrity.

What is the use of DBCC commands?

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.

Can you give me some DBCC command options?(Database consistency check)

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.

What command do we use to rename a db?

sp_renamedb ‘oldname’ , ‘newname’


Well sometimes sp_reanmedb may not work you know because if some one is using the db it will
not accept this command so what do you think you can do in such cases?

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.

What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?

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.

What do you mean by COLLATION?

Collation is basically the sort order. There are three types of sort order Dictionary case sensitive, Dictonary -
case insensitive and Binary.

What is a Join in SQL Server?

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

When do you use SQL Profiler?

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..

What is a Linked Server?

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.

Which stored procedure will you be running to add a linked server?

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)

Can you explain the role of each service?

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.

What are the authentication modes in SQL Server?

Windows mode and mixed mode (SQL & Windows).

Where do you think the users names and passwords will be stored in sql server?

They get stored in master db in the sysxlogins table.

What is log shipping? Can we do logshipping with SQL Server 7.0

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?

(I am not sure- but I think we have a command to do it).

What is BCP? When do we use it?

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?

We have to write some DTS packages for it.


C# Interview Questions

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.

2.How do you inherit from a class in C#?

Place a colon and then the name of the base class. Notice that it’s double colon in C++.

3.Does C# support multiple inheritances?

No, use interfaces instead.

4.When you inherit a protected class-level variable, who is it available to?

Classes in the same namespace.

5.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. But they
are.

6.Describe the accessibility modifier protected internal.

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.

8.What’s the top .NET class that everything is derived from?

System. Object.

9.How’s method overriding different from overloading?

When overriding, you change the method behavior for a derived class. Overloading simply involves having a
method with the same name within the class.

10.What does the keyword virtual mean in the method definition?

The method can be over-ridden.

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.

12.Can you override private virtual methods?

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.

15.What’s an abstract class?

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.

17.What’s an interface class?

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.

19.Can you inherit multiple interfaces?

Yes, why not.

20.And if they have conflicting method names?

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.

21.What’s the difference between an interface and abstract class?

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.

22.How can you overload a method?

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.

25.What’s the advantage of using System.Text.StringBuilder over System? String?

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.

26.Can you store multiple data types in System? Array?

No.

27.What’s the difference between the System.Array.CopyTo () and System.Array.Clone ()?

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?

By calling Sort () and then Reverse () methods.

29.What’s the .NET data type that allows the retrieval of data by a unique key?

Hash Table.

30.What’s class Sorted List underneath?


 
A sorted 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 {}.

33.Can multiple catch blocks be executed?

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.

34.Why is it a bad idea to throw your own exceptions?

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.

38.What are the ways to deploy an assembly?

An MSI installer, a CAB archive, and XCOPY command.

39.What’s a satellite 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.

40.What namespaces are necessary to create a localized application?

System. Globalization, System. Resources.

41.What’s the difference between // comments, /* */ comments and /// comments?

Single-line, multi-line and XML documentation comments.

42.How do you generate documentation from the C# file commented properly with a command-line
compiler?

Compile it with a /doc switch.

43.What’s the difference between <c> and <code> XML documentation tag?

Single line code example and multiple-line code example.

44.Is XML case-sensitive?

Yes, so <Student> and <student> are different elements.

45.What debugging tools come with the .NET SDK?

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.

46.What does the window show in the debugger?

It points to the object that’s pointed to by this reference. Object’s instance data is shown.

47.What does assert () do?

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.

49.Why are there five tracing levels in System.Diagnostics.TraceSwitcher?

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.

50.Where is the output of TextWriterTraceListener redirected?

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?

Attach the aspnet_wp.exe process to the DbgClr debugger.

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).

53.Can you change the value of a variable while debugging a C# application?

Yes, if you are debugging via Visual Studio.NET, just go to immediate window.

54.Explain the three services model (three-tier application).

Presentation (UI), business (logic and underlying code) and data (from storage or other sources).

55.What are advantages and disadvantages of Microsoft-provided data provider classes in


ADO.NET?

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.

56.What’s the role of the Data Reader class in ADO.NET connections?

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%’.

58.Explain ACID rule of thumb for transactions.

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).

59.What connections does Microsoft SQL Server support?

Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server
username and passwords).

60.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

9
the transaction.

61.Why would you use untrusted verification?

Web Services might use it, as well as non-Windows applications.

62.What does the parameter Initial Catalog define inside Connection String?

The database name to connect to.

63.What’s the data provider name to connect to Access database?

Microsoft. Access.

64.What does dispose method do with the connection object?

Deletes it from the memory.

65.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.

1.Is it possible to inline assembly or IL in C# code?

- No.

2. Is it possible to have different access modifiers on the get/set methods of a property?


- No. The access modifier on a property applies to both its get and set accessors. What you need to do if
you want them to be different is make the property read-only (by only providing a get accessor) and create a
private/internal set method that is separate from the property.

3. Is it possible to have a static indexer in C#?

- No. Static indexers are not allowed in C#.

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) { }

6. How does one compare strings in C#?

- 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? -

[Obsolete] public int Foo() {...}

or

[Obsolete(\"This is a message describing why this method is obsolete\")] public int Foo() {...}

Note: The O in Obsolete is always capitalized.

9.How do you implement thread synchronization (Object.Wait, Notify,and CriticalSection) in C#?

- 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?

- Here’s a quick example of the DllImport attribute in action:

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.

11.How do I simulate optional parameters to COM calls?

- 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.

2.Why does DllImport not work for me?

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?

- The word checked is a keyword in C#.

6.Why do I get a security exception when I try to run my C# app?

- 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() {} }

10.What is the equivalent to regsvr32 and regsvr32 /u a file in .NET development?

- Try using RegAsm.exe. Search MSDN on Assembly Registration Tool.

11.What is the difference between a struct and a class in C#?

- 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.

12.My switch statement works differently than in C++! Why?

- 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;
}
}
}

13.Is there regular expression (regex) support available to C# developers?

- Yes. The .NET class libraries provide support for regular expressions. Look at the
System.Text.RegularExpressions namespace.

14.Is there any sample C# code for simple threading?

- 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();
}
}

15.Is there an equivalent of exit() for quitting a C# .NET application?

- Yes, you can use System.Environment.Exit(int exitCode) to exit the application or Application.Exit() if it’s a
Windows Forms app.

16. Is there a way to force garbage collection?

- 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?

- The easiest way is to use goto:

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.

1. The most important DDL statements in SQL are:

CREATE TABLE - creates a new database table


ALTER TABLE - alters (changes) a database table
DROP TABLE - deletes a database table
CREATE INDEX - creates an index (search key)
DROP INDEX - deletes an index
2. Operators used in SELECT statements.

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

 3. SELECT statements:

SELECT column_name(s) FROM table_name


SELECT DISTINCT column_name(s) FROM table_name
SELECT column FROM table WHERE column operator value
SELECT column FROM table WHERE column LIKE pattern
SELECT column,SUM(column) FROM table GROUP BY column
SELECT column,SUM(column) FROM table GROUP BY column HAVING SUM(column) condition value
Note that single quotes around text values and numeric values should not be enclosed in quotes. Double
quotes may be acceptable in some databases.

 4. The SELECT INTO Statement is most often used to create backup copies of tables or for archiving
records.

SELECT column_name(s) INTO newtable [IN externaldatabase] FROM source


SELECT column_name(s) INTO newtable [IN externaldatabase] FROM source WHERE column_name
operator value

 5. The INSERT INTO Statements:

INSERT INTO table_name VALUES (value1, value2,....)


INSERT INTO table_name (column1, column2,...) VALUES (value1, value2,....)

 6. The Update Statement:

UPDATE table_name SET column_name = new_value WHERE column_name = some_value


7. The Delete Statements:
DELETE FROM table_name WHERE column_name = some_value
Delete All Rows:
DELETE FROM table_name or DELETE * FROM table_name

 8. Sort the Rows:

SELECT column1, column2, ... FROM table_name ORDER BY columnX, columnY, ..


SELECT column1, column2, ... FROM table_name ORDER BY columnX DESC
SELECT column1, column2, ... FROM table_name ORDER BY columnX DESC, columnY ASC

 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 IN (value1,value2,..)

 10. BETWEEN ... AND

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.

 12. Why does the following command give a compilation error?

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.

 15. What is the difference between TRUNCATE and DELETE commands?

 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.

 21. Which command executes the contents of a specified file?

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;?

sal = 11000, comm = 1000.

 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.

 27. What operator performs pattern matching?

LIKE operator.

 28. What is the use of the DROP option in the ALTER TABLE command?

It is used to drop constraints specified on the table.

 29. What operator tests column for the absence of data?

IS NULL operator.

 30. What are the privileges that can be granted on a table by a user to others?

Insert, update, delete, select, references, index, execute, alter, all.


31. Which function is used to find the largest integer less than or equal to a specific value?
FLOOR.

 32. Which is the subset of SQL commands used to manipulate Oracle Database structures, including
tables?

Data Definition Language (DDL).

 33. What is the use of DESC in SQL?

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?

CREATE TABLE .. AS SELECT command


Explanation:
To copy only the structure, the WHERE clause of the SELECT command should contain a FALSE statement
as in the following.
CREATE TABLE NEWTABLE AS SELECT * FROM EXISTINGTABLE WHERE 1=2;
If the WHERE condition is true, then all the rows or rows satisfying the condition will be copied to the new
table.
35. TRUNCATE TABLE EMP;DELETE FROM EMP;
Will the outputs of the above two commands differ?
Both will result in deleting all the rows in the table EMP..
36. What is the output of the following query SELECT TRUNC(1234.5678,-2) FROM DUAL;?
1200.
37. What are the wildcards used for pattern matching.?

18
_ for single character substitution and % for multi-character substitution.

 38. What is the parameter substitution symbol used with INSERT INTO command?

&

 39. What's an SQL injection?

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.

 41. What is a join? Explain the different types of joins?

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.

 43. What is correlated sub-query?

Correlated sub-query is a sub-query, which has reference to the main query.

 44. Explain CONNECT BY PRIOR?

Retrieves rows in hierarchical order eg.


select empno, ename from emp where.

 45. Difference between SUBSTR and INSTR?

INSTR (String1, String2 (n, (m)),


INSTR returns the position of the m-th occurrence of the string 2 in string1. The search begins from nth
position of string1.
SUBSTR (String1 n, m)
SUBSTR returns a character string of size m in string1, starting from n-th position of string1.

 46. Explain UNION, MINUS, UNION ALL and INTERSECT?

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.

 47. What is ROWID?

ROWID is a pseudo column attached to each row of a table. It is 18 characters long, blockno, rownumber
are the components of ROWID.

 48. What is the fastest way of accessing a row in a table?

19
Using ROWID.
CONSTRAINTS
49. What is an integrity constraint?
Integrity constraint is a rule that restricts values to a column in a table.

 50. What is referential integrity constraint?

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.

 51. What is the usage of SAVEPOINTS?

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.

 52. What is ON DELETE CASCADE?

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.

 53. What are the data types allowed in a table?

CHAR, VARCHAR2, NUMBER, DATE, RAW, LONG and LONG RAW.

 54. What is difference between CHAR and VARCHAR2? What is the maximum SIZE allowed for each
type?

CHAR pads blank spaces to the maximum length.


VARCHAR2 does not pad blank spaces.
For CHAR the maximum length is 255 and 2000 for VARCHAR2.
55. How many LONG columns are allowed in a table? Is it possible to use LONG columns in WHERE
clause or ORDER BY?
Only one LONG column is allowed. It is not possible to use LONG column in WHERE or ORDER BY clause.

 56. What are the pre-requisites to modify datatype of a column and to add a column with NOT NULL
constraint?

- To modify the datatype of a column the column must be empty.


- To add a column with NOT NULL constrain, the table must be empty.

 57. Where the integrity constraints are stored in data dictionary?

The integrity constraints are stored in USER_CONSTRAINTS.

 58. How will you activate/deactivate integrity constraints?

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.

 60. What is a database link?

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.

 60.What is CYCLE/NO CYCLE in a Sequence?

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.

 61. What are the advantages of VIEW?

- To protect some of the columns of a table from other users.


- To hide complexity of a query.
- To hide complexity of calculations.

 62. Can a view be updated/inserted/deleted? If Yes - under what conditions?

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.

 65. Which of the following is not a feature of a cursor FOR loop?

1. Record type declaration.


2. Opening and parsing of SQL statements.
3. Fetches records from cursor.
4. Requires exit condition to be defined.
66. A developer would like to use referential datatype declaration on a variable. The variable name is
EMPLOYEE_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 LASTNAME table and use that.
4. Declare it to be type LONG.

 67. Which three of the following are implicit cursor attributes?

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.

 70. The command used to open a CURSOR FOR loop is

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

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 current row values

 72. Read the following code:


10. CREATE OR REPLACE PROCEDURE find_cpt
11. (v_movie_id {Argument Mode} NUMBER, v_cost_per_ticket {argument mode} NUMBER)
12. IS
13. BEGIN
14. IF v_cost_per_ticket > 8.5 THEN
15. SELECT cost_per_ticket
16. INTO v_cost_per_ticket
17. FROM gross_receipt
18. WHERE movie_id = v_movie_id;
19. END IF;
20. END;
Which mode should be used for V_COST_PER_TICKET?
1. IN
2. OUT
3. RETURN
4. IN OUT

73. Read the following code:


22. CREATE OR REPLACE TRIGGER update_show_gross
23. {trigger information}
24. BEGIN
25. {additional code}
26. 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
22
3. WHERE (new.cost_per_ticket > 3.75)
4. WHERE (:new.cost_per_ticket > 3.75)

 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

 78. Read the following code:


CREATE OR REPLACE FUNCTION get_budget(v_studio_id IN NUMBER)
RETURN number IS
v_yearly_budget NUMBER;
BEGIN
SELECT yearly_budget
INTO v_yearly_budget
FROM studio
WHERE 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 NUMBER
EXECUTE g_yearly_budget := GET_BUDGET(11);
2. VARIABLE g_yearly_budget NUMBER
EXECUTE :g_yearly_budget := GET_BUDGET(11);
3. VARIABLE :g_yearly_budget NUMBER
EXECUTE :g_yearly_budget := GET_BUDGET(11);
4. VARIABLE g_yearly_budget NUMBER

31. CREATE OR REPLACE PROCEDURE update_theater


32. (v_name IN VARCHAR v_theater_id IN NUMBER) IS
33. BEGIN
34. UPDATE theater
35. SET name = v_name
36. WHERE id = v_theater_id;
37. END update_theater;

79. 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 this error?

1. An user defined exception must be declared and associated


with the error code and handled in the EXCEPTION section.
2. Handle the error in EXCEPTION section by referencing the error
code directly.
3. Handle the error in the EXCEPTION section by referencing the UNIQUE_ERROR predefined exception.
4. Check for success by checking the value of SQL%FOUND immediately after the UPDATE statement.

80. Read the following code:

40. CREATE OR REPLACE PROCEDURE calculate_budget IS

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. The GET_BUDGET function will be marked invalid and must be recompiled


before the next execution.
2. The SET_BUDGET function will be marked invalid and must be recompiled
before the next execution.
3. Only the CALCULATE_BUDGET procedure needs to be recompiled.
4. All three procedures are marked invalid and must be recompiled.

81. Which procedure can be used to create a customized error message?

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?

1. ALTER TRIGGER check_theater ENABLE;


2. ENABLE TRIGGER check_theater;
3. ALTER TABLE check_theater ENABLE check_theater;
4. ENABLE check_theater;

83. Examine this database trigger


52. CREATE OR REPLACE TRIGGER prevent_gross_modification
53. {additional trigger information}
54. BEGIN
55. IF TO_CHAR(sysdate, DY) = MON
56. THEN
57. RAISE_APPLICATION_ERROR(-20000,Gross receipts cannot be deleted on
Monday);
58. END IF;
59. END;
This trigger must fire before each DELETE of the GROSS_RECEIPT table.
It should fire only once for the entire DELETE statement. 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
84. Examine this function:
61. CREATE OR REPLACE FUNCTION set_budget
62. (v_studio_id IN NUMBER, v_new_budget IN NUMBER) IS
63. BEGIN
64. UPDATE studio
65. SET yearly_budget = v_new_budget
WHERE id = v_studio_id;
24
IF SQL%FOUND THEN
RETURN TRUEl;
ELSE
RETURN FALSE;
END IF;
COMMIT;
END;
Which code must be added to successfully compile this function?

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.

85. Under which circumstance must you recompile the package body
after recompiling the package specification?

1. Altering the argument list of one of the package constructs


2. Any change made to one of the package constructs
3. Any SQL statement change made to one of the package constructs
4. Removing a local variable from the DECLARE section of one of the
package constructs

86. 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 the trigger
4. During a data manipulation statement and when the transaction
is committed

87. 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

88. What occurs if a procedure or function terminates with failure


without being handled?

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.

89. Examine this code


71. BEGIN
72. theater_pck.v_total_seats_sold_overall := theater_pck.get_total_for_year;
73. END;
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
25
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.

90 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 this feature?

1. DBMS_DDL
2. DBMS_DML
3. DBMS_SYN
4. DBMS_SQL

91 How to implement ISNUMERIC function in SQL *Plus ?

Method 1:

Select length (translate(trim (column_name),'+-.0123456789',''))from dual;

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;

It returns 0 if it is a number, 1 if it is not.

92 How to Select last N records from a Table?

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.

Cursor rem_master(brepno VARCHAR2) IS


select a.* from ter.ter_master a
where NOT a.repno in (select repno from ermast) and
(brepno = 'ALL' or a.repno > brepno)
Order by a.repno

What are steps required tuning this query to improve its performance?

-Have an index on TER_MASTER.REPNO and one on ERMAST.REPNO


-Be sure to get familiar with EXPLAIN PLAN. This can help you determine the execution
path that Oracle takes. If you are using Cost Based Optimizer mode, then be sure that
your statistics on TER_MASTER are up-to-date. -Also, you can change your SQL to:

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

94. What does preemptive in preemptive multitasking mean ?

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.

95. What does the OLTP stands for ?

OLTP stands for On Line Transaction Processing

96. What is the most important requirement for OLTP ?

OLTP requires real time response.

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.

98. Why is the most of the processing done at the sever ?

To reduce the network traffic and for application sharing and implementing business rules.

99. What does teh term upsizing refer to ?

Applications that have outgrown their environment are re-engineered to run in a larger environment. This is
upsizing.

100. What does one do when one is rightsizing ?

With rightsizing, one would move applications to the most appropriate server platforms.

101. What does the term downsizing refer to ?

A host based application is re-engineered to run in smaller or LAN based environment.

102. What is event trigger ?

An event trigger, a segment of code which is associated with each event and is fired
when the event occurs.

103. Why do stored procedures reduce network traffic ?

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 ?

Foreground process and Background process.

105. What is a event handler ?

An event handler is a routine that is written to respond to a particular event.

106. What is an integrity constraint ?

An integrity constraint allows the definition of certain restrictions, at the table level, on the data that is
entered into a table.

107. What are the various uses of database triggers ?

Database triggers can be used to enforce business rules, to maintain derived values
and perform value-based auditing.

108. What is a transaction ?


A transaction is a set of operations that begin when the first DML is issued and end
when a commit or rollback is issued. BEGIN COMMIT/ROLLBACK are the boundries of
a transaction.

109. Why are the integrity constraints preferred to database triggers ?

Because it is easier to define an integrity constraint than a database trigger.

110. Why is it better to use an integrity constraint to validate data in a table than to use a stored
procedure ?

Because an integrity constraint is automatically checked while data is inserted into


a table. A stored has to be specifically invoked.

111. What are the three components of a client server model ?

A Client,
A Server and
A Network/Communication software.

112. What are the advantages of client/server model ?

Flexibility of the system, scalability, cost saving, centralised control and implementation of business rules,
increase of developers productivity, portability, improved network and resource utilization.

113. What are the disadvantages of the client/server model ?

Heterogeneity of the system results in reduced reliablity. May not be suitable for all applications. Managing and
tuning networks becomes difficult.

114. What are the different topologies available for network ?

Star,
Bus,
Ring.

115. What is the first work of Client process ?


28
A client process at first establishes connection with the Server.

115. What are the responsibilities of a Server ?

1. Manage resources optimally across multiple clients.


2. Controlling database access and security.
3. Protecting the databse and recovering it from crashes.
4. Enforcing integrity rules globally.

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.

117. Give some examples of standard API??s ?

Open Database Connectivity (ODBC),


Integrated Database Application Programming Interface (IDAPI),
XOpen
SQL/CLI

118. What is the main advantage of developing an application using an API ?

The application can be connected to any back end server that is supported by the API.

119. What is the main disadvantage of developing an application using an API ?

The application cannot use any special features of the backend server.

120. Why is an event driven program referred to a passive program ?

Because an event driven program is always waiting for something to happen before processing.

120. What are the four types of events ?

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.

122. What is inheritance ?

Inheritance is a method by which properties and methods of an existing object are automatically passed to any
object derived from it.

123. What are the two components of ODBC ?

1. An ODBC manager/administrator and


2. ODBC driver.

124. What is the function of a ODBC manager ?

29
The ODBC Manager manages all the data sources that exists in the system.

125. What is the function of a ODBC Driver ?

The ODBC Driver allows the developer to talk to the back end database.

126. What description of a data source is required for ODBC ?

The name of the DBMS, the location of the source and the database dependent
information.

127. How is a connection establised by ODBC ?

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.

1. Does C# support multiple-inheritance?


No.
 
2. Who is a protected class-level variable available to?
It is available to any sub-class (a class inheriting this class).
 
3. Are private class-level variables inherited?
Yes, but they are not accessible.  Although they are not visible or accessible via the class interface, they
are inherited. 
 
4. Describe the accessibility modifier “protected internal”.
It is available to classes that are within the same assembly and derived from the specified base class. 
 
5. What’s the top .NET class that everything is derived from?
System.Object. 
 
6. What does the term immutable mean?
The data value may not be changed.  Note: The variable value may be changed, but the original
immutable data value was discarded and a new data value was created in memory. 
 
7. What’s the difference between System.String and System.Text.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. 
 
8. What’s the advantage of using System.Text.StringBuilder over System.String?
StringBuilder is more efficient in cases where there is a large amount of string manipulation.  Strings are
immutable, so each time a string is changed, a new instance in memory is created.
 
9. Can you store multiple data types in System.Array?
No. 
 
10. What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
The Clone() method returns a new array (a shallow copy) object containing all the elements in the original
array.  The CopyTo() method copies the elements into another existing array.  Both perform a shallow
copy.  A shallow copy means the contents (each array element) contains references to the same object as
the elements in the original array.  A deep copy (which neither of these methods performs) would create a
new instance of each element's object, resulting in a different, yet identacle object.
 
11. How can you sort the elements of the array in descending order?
By calling Sort() and then Reverse() methods. 
 
30
12. What’s the .NET collection class that allows an element to be accessed using a unique key?
HashTable. 
 
13. What class is underneath the SortedList class?
A sorted HashTable. 
 
14. Will the finally block get executed if an exception has not occurred?
Yes.
 
15. What’s the C# syntax to catch 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 {}. 
 
16. Can multiple catch blocks be executed for a single try statement?
No.  Once the proper catch block processed, control is transferred to the finally block (if there are any). 
 
17. Explain the three services model commonly know as a three-tier application.
Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources). 
 

Class Questions

1. What is the syntax to inherit from a class in C#?


Place a colon and then the name of the base class.
Example: class MyNewClass : MyBaseClass 
 
2. Can you prevent your class from being inherited by another class?
Yes.  The keyword “sealed” will prevent the class from being inherited. 
 
3. Can you allow a class to be inherited, but prevent the method from being over-ridden?
Yes.  Just leave the class public and make the method sealed. 
 
4. What’s an abstract class?
A class that cannot be instantiated.  An abstract class is a class that must be inherited and have the
methods overridden.  An abstract class is essentially a blueprint for a class without any implementation. 
 
5. When do you absolutely have to declare a class as abstract?
1. When the class itself is inherited from an abstract class, but not all base abstract methods have been
overridden.
2.  When at least one of the methods in the class is abstract. 
 
6. What is an interface class?
Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do
not provide implementation. They are implemented by classes, and defined as separate entities from
classes. 
 
7. Why can’t you specify the accessibility modifier for methods inside the interface?
They all must be public, and are therefore public by default. 
 
8. Can you inherit multiple interfaces?
Yes.  .NET does support multiple interfaces. 
 
9. What happens if you inherit multiple interfaces and they have conflicting method names?
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.
To Do: Investigate 
 
31
10. What’s the difference between an interface and abstract class?
In an interface class, all methods are abstract - there is no implementation.  In an abstract class some
methods can be concrete.  In an interface class, no accessibility modifiers are allowed.  An abstract class
may have accessibility modifiers. 
 
11. What is the difference between a Struct and a Class?
Structs are value-type variables and are thus saved on the stack, additional overhead but faster retrieval. 
Another difference is that structs cannot inherit. 
 

Method and Property 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.
 

Events and Delegates

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.
 

XML Documentation Questions

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

1. What debugging tools come with the .NET SDK?


1.   CorDBG – command-line debugger.  To use CorDbg, you must compile the original C# file using the
/debug switch.
2.   DbgCLR – graphic debugger.  Visual Studio .NET uses the DbgCLR. 
 
2. What does assert() method do?
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. 
 
3. 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. 
 
4. Why are there five tracing levels in System.Diagnostics.TraceSwitcher?
The tracing dumps can be quite verbose.  For applications that are constantly running you run the risk of
overloading the machine and the hard drive.  Five levels range from None to Verbose, allowing you to fine-
tune the tracing activities. 
 
5. Where is the output of TextWriterTraceListener redirected?
To the Console or a text file depending on the parameter passed to the constructor. 
 
6. How do you debug an ASP.NET Web application?
Attach the aspnet_wp.exe process to the DbgClr debugger. 
 
7. What are three test cases you should go through in unit testing?
1.       Positive test cases (correct data, correct output).
2.       Negative test cases (broken or missing data, proper handling).
3.       Exception test cases (exceptions are thrown and caught properly). 
 
8. Can you change the value of a variable while debugging a C# application?
Yes.  If you are debugging via Visual Studio.NET, just go to Immediate window. 
 

ADO.NET and Database Questions

1. What is the role of the DataReader class in ADO.NET connections?


It returns a read-only, forward-only rowset from the data source.  A DataReader provides fast access when
a forward-only sequential read is needed. 
 
2. What are advantages and disadvantages of Microsoft-provided data provider classes in
ADO.NET?
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.  OLE-DB.NET is a .NET layer on top of the OLE layer, so it’s not as fastest and efficient as
SqlServer.NET. 
 
3. 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%’. 
 
4. Explain ACID rule of thumb for transactions.
A transaction must be:
1.       Atomic - it is one unit of work and does not dependent on previous and following transactions.
2.       Consistent - data is either committed or roll back, no “in-between” case where something has been
updated and something hasn’t.
3.       Isolated - no transaction sees the intermediate results of the current transaction).

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

1. How is 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. 
 
2. What are the ways to deploy an assembly?
An MSI installer, a CAB archive, and XCOPY command. 
 
3. What is a satellite 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. 
 
4. What namespaces are necessary to create a localized application?
System.Globalization and System.Resources.
 
5. What is the smallest unit of execution in .NET?
an Assembly.
 
6. When should you call the garbage collector in .NET?
As a good rule, you should not call the garbage collector.  However, you could call the garbage collector
when you are done using a large object (or set of objects) to force the garbage collector to dispose of those
very large objects from memory.  However, this is usually not a good practice.
 
7. How do you convert a value-type to a reference-type?
Use Boxing.
 
8. What happens in memory when you Box and Unbox a value-type?
Boxing converts a value-type to a reference-type, thus storing the object on the heap.  Unboxing converts a
reference-type to a value-type, thus storing the value on the stack.

34

You might also like