Interview Tips Interview Tips, Interview Questions and Answers

1Oct/110

Code Issues specific to partial methods

There are several conditions that are applied to partial methods, such as:

    Partial methods must be void
    Signatures of both parts of partial methods must match
    Access modifiers are not allowed for partial methods
    Partial methods must be declared in partial classes
    etc

You don’t have to remember all these conditions if you have the CodeRush code issues feature turned on. When the rule of the partial method declaration is violated, code issues will show you an error or a hint, and you can fix it before you compile the code. These code issues are:
Partial method cannot have access modifiers or the virtual, abstract, override, new, sealed, or extern modifiers

If a partial method has an invalid modifier (e.g., virtual, abstract, override, new, sealed, extern, or an access modifier) you will see an error in the code editor, because partial methods cannot have these type of modifiers:
CodeRush Partial method cannot have modifiers
CodeRush Partial method cannot have access modifiers
Partial method cannot have out parameters

Out parameters are not allowed for partial methods. If a partial method is declared with ‘out’ parameters, you will see an error:

CodeRush Partial method cannot have out parameters
Partial method must be declared within a partial class or partial struct

Partial methods can only reside inside a partial class or a partial structure, otherwise, an error is shown:

CodeRush Partial method must be declared within a partial class
Partial method has only single part

When the partial method has only a single part without a declaration, it does not need to be declared as partial. This code issue has a hint type:

CodeRush Partial method has only single part
2May/100

Explain the concepts of CTS and CLS(Common Language Specification).

CTS

When different languages are integrated and want to communicate, it is certain that the languages have their own data types and different declaration styles. CTS define how these different variables are declared and used in run time. E.g. VB offers an Integer data type while C++ offers long data type. Using CTS, these data types are converted to System32 which itself a data type of CLS.

CLS

Any language(s) that intend to use the Common Language Infrastructure needs to communicate with other CLS-Compliant language. This communication is based on set of rules laid by CLS. These rules define a subset of CTS.

22Dec/090

5 Frequently asked JSP Interview Questions

Q:  What is a Expression?
A: An expression tag contains a scripting language expression that is evaluated, converted to a String, and inserted where the expression appears in the JSP file. Because the value of an expression is converted to a String, you can use an expression within text in a JSP file. Like
<%= someexpression %>
<%= (new java.util.Date()).toLocaleString() %>
You cannot use a semicolon to end an expression

Q: What is a Declaration?
A: A declaration declares one or more variables or methods for use later in the JSP source file.

A declaration must contain at least one complete declarative statement. You can declare any number of variables or methods within one declaration tag, as long as they are separated by semicolons. The declaration must be valid in the scripting language used in the JSP file.

<%! somedeclarations %>
<%! int i = 0; %>
<%! int a, b, c; %>

Q:  What is a Scriptlet?

A: A scriptlet can contain any number of language statements, variable or method declarations, or expressions that are valid in the page scripting language.Within scriptlet tags, you can

1.Declare variables or methods to use later in the file (see also Declaration).

2.Write expressions valid in the page scripting language (see also Expression).

3.Use any of the JSP implicit objects or any object declared with a <jsp:useBean> tag.
You must write plain text, HTML-encoded text, or other JSP tags outside the scriptlet.

Scriptlets are executed at request time, when the JSP engine processes the client request. If the scriptlet produces output, the output is stored in the out object, from which you can display it.