 |
Click here for
Enquiry Form |
TEK-BASE is a knowledge
database that is available for our employees and students.
They will have 24 / 7 access to the full database to post,
read, share and discuss any of the technical questions
they have. The questions range from simple explanation
of a term to the complex coding logic.
Provided below is a
snapshot from the database ...
.NET SNAP SHOT
| What are valid signatures for the
Main function? |
public static void Main()
public static int Main()
public static void Main( string[] args )
public static int Main(string[] args ) |
| How do you initialize a two-dimensional
array that you don’t know the dimensions
of? |
int [, ] myArray; //declaration
myArray= new int [5, 8]; //actual initialization
|
| What’s the
difference between const and readonly? |
| You can initialize readonly variables to
some runtime values. Let’s say your
program uses current date and time as one
of the values that won’t change. This
way you declare public readonly string DateT
= new DateTime().ToString(). |
| How do you generate
an RCW from a COM object? |
| Use the Type Library Import utility shipped
with SDK. tlbimp COMobject.dll /out:.NETobject.dll
or reference the COM library from Visual Studio
in your project. |
| How do you turn off SessionState
in the web.config file? |
In the system.web section of web.config,
you should locate the httpmodule tag and you
simply disable session by doing a remove tag
with attribute name set to session. <httpModules>
<remove name="Session” />
</httpModules> |
| What’s the
difference between struct and class in C#?
|
Structs cannot be inherited.
Structs are passed by value, not by reference.
Struct is stored on the stack, not the heap. |
| Which method do
you invoke on the DataAdapter control to load
your generated dataset with data? |
System.Data.Common.DataAdapter.Fill(System.Data.DataSet);
If my DataAdapter is sqlDataAdapter and my
DataSet is dsUsers then it is called this
way:
sqlDataAdapter.Fill(dsUsers); |
| 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. |
| What is type system
unification? |
The goal of type system unification is to
bridge the gap between value types and reference
types that exists in most languages. For example,
a Stack class can provide Push and Pop methods
that take and return object values.
public class Stack
{
public object Pop() {...}
public void Push(object o) {...}
}
Because C# has a unified type system, the
Stack class can be used with elements of any
type, including value types like int. |
| In what order
do the events of an ASPX page execute. As
a developer is it important to undertsand
these events? |
| Every Page object (which your .aspx page
is) has nine events, most of which you will
not have to worry about in your day to day
dealings with ASP.NET. The three that you
will deal with the most are: Page_Init, Page_Load,
Page_PreRender. |
|
JAVA SNAP SHOT
| How to register
a connection to a database with a JNDI name
and use the JNDI name specified? |
| The way in which
you access your database from an Application
Server is vendor specific. Usually, you define
a connection by specifying a JDBCdriver in
your Application Server's config file. You
supply the driver along with a user/password
to your database (although this too is database
and driver specific). Once you've done this,
your Application Server will automatically
register the connection in JNDI and possibly
create a pool of connections. With Entity
Beans, you can define which connection you
wish to use inside the deployment descriptor.
With Session Beans using JDBC, you lookup
the name of the connection you've configured
with JNDI. |
| What is the default
time for transaction manager? And how to set
maximum time(timeout) for transaction?. |
The default time depends
on your app server. It is usually around 30
seconds. If you are using bean-managed transactions,
you can set it like this:
// One of the methods from the SessionBean
interface
public void setSessionContext(SessionContext
context) throws EJBException
{
sessionContext = context;
}
// Then, when starting a new transaction
UserTransaction userTransaction = sessionContext.getUserTransaction();
userTransaction.setTransactionTimeout(60);
userTransaction.begin();
// do stuff
userTransaction.commit();
If you are using container-managed transactions,
this value is set in a app server specific
way. Check your app server's deployment descriptor
DTD. |
| Is
there a way to get the original exception
object from inside a nested or wrapped Exception
(for example an EJBException or RemoteException)? |
Absolutely yes, but the
way to do that depends on the Exception, since
there are no standards for that.
Some examples:
When you have an javax.ejb.EJBException, you
can use the getCausedByException() that returns
a java.lang.Exception.
A java.rmi.RemoteException there is a public
field called detail of type java.lang.Throwable
With a java.sql.SQLException you need to use
the method getNextException() to get the chained
java.sql.SQLException.
When you have an java.lang.reflect.InvocationtargetException,
you can get the thrown target java.lang.Throwable
using the getTargetException() method. |
| Calling
a Action Class from another Action class
|
You can easily forward between
actions by specifiying the action as another
forward in the struts configuration file:
<action path="/actions/firstAction"
type="example.SecurityAction"
scope="request"> <forward
name="success"
path="/actions/secondAction.do"/>
<forward name="failure"
path="/pages/login.jsp"/>
</action> <action path="/actions/secondAction"
type="example.BusinessAction" scope="request">
<forward name="success" page="/pages/businessPage.jsp"/>
</action> |
| Why is the form
bean automatically created by both servlet
and form tag? |
| It is valid for a user to
enter the system either through the servlet
or through the JSP form, and so the bean must
be created in either place. |
| What
is the default time for transaction manager?
And how to set maximum time(timeout) for transaction?.
|
The default time depends
on your app server. It is usually around 30
seconds. If you are using bean-managed transactions,
you can set it like this:
// One of the methods from the SessionBean
interface
public void setSessionContext(SessionContext
context) throws EJBException
{
sessionContext = context;
}
// Then, when starting a new transaction
UserTransaction userTransaction = sessionContext.getUserTransaction();
userTransaction.setTransactionTimeout(60);
userTransaction.begin();
// do stuff
userTransaction.commit();
If you are using container-managed transactions,
this value is set in a app server specific
way. Check your app server's deployment descriptor
DTD.
As usual, the best way to check how to get
that piece of information is to read the documentation
of the specific Exception |
| How
to suppress the URL shown in the address bar?
No matter what page the customer is on, I
want to just show http://sitename.com and
no JSP page name. |
Try using a hidden frame,
similar to this: <frameset rows="0,*"
framespacing="0" frameborder="0"
border="0"> <frame name="hiddenfrm"
src="blank.jsp" scrolling="no"
noresize> <frame name="content"
src="home.jsp" noresize> </frameset>
|
|
|
|