Interview Tips Interview Tips, Interview Questions and Answers

22May/100

What is the difference between String and StringBuilder?

Both String and StringBuilder are classes used to handle strings.

The most common operation with a string is concatenation. This activity has to be performed very efficiently. When we use the "String" object to concatenate two strings, the first string is combined to the other string by creating a new copy in the memory as a string object, and then the old string is deleted. This process is a little long. Hence we say "Strings are immutable".

When we make use of the "StringBuilder" object, the Append method is used. This means, an insertion is done on the existing string. Operation on StringBuilder object is faster than String operations, as the copy is done to the same location. Usage of StringBuilder is more efficient in case large amounts of string manipulations have to be performed.

9Mar/100

C# Interview Questions & Answers :

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.

18Feb/100

C# Interview Questions and Answers

1) The C# keyword ?int? maps to which .NET type?

  1. System.Int16

  2. System.Int32

  3. System.Int64

  4. System.Int128

2) Which of these string definitions will prevent escaping on backslashes in C#?

  1. string s = #?n Test string?;

  2. string s = ??n Test string?;

  3. string s = @?n Test string?;

  4. string s = ?n Test string?;

3) Which of these statements correctly declares a two-dimensional array in C#?

  1. int[,] myArray;

  2. int[][] myArray;

  3. int[2] myArray;

  4. System.Array[2] myArray;

4) If a method is marked as protected internal who can access it?

  1. Classes that are both in the same assembly and derived from the declaring class.

  2. Only methods that are in the same class as the method in question.

  3. Internal methods can be only be called using reflection.

  4. Classes within the same assembly, and classes derived from the declaring class.

5) What is boxing?

a) Encapsulating an object in a value type.

b) Encapsulating a copy of an object in a value type.

c) Encapsulating a value type in an object.

d) Encapsulating a copy of a value type in an object.

6) What compiler switch creates an xml file from the xml comments in the files in an assembly?

  1. /text

  2. /doc

  3. /xml

  4. /help

7) What is a satellite Assembly?

  1. A peripheral assembly designed to monitor permissions requests from an application.

  2. Any DLL file used by an EXE file.

  3. An assembly containing localized resources for another assembly.

  4. An assembly designed to alter the appearance or ?skin? of an application.

8) What is a delegate?

  1. A strongly typed function pointer.

  2. A light weight thread or process that can call a single method.

  3. A reference to an object in a different process.

  4. An inter-process message channel.

9) How does assembly versioning in .NET prevent DLL Hell?

  1. The runtime checks to see that only one version of an assembly is on the machine at any one time.

  2. .NET allows assemblies to specify the name AND the version of any assemblies they need to run.

  3. The compiler offers compile time checking for backward compatibility.

  4. It doesn?t.

10) Which ?Gang of Four? design pattern is shown below?

public class A {

    private A instance;

    private A() {

    }

    public
static A Instance {

        get

        {

            if ( A == null )

                A = new A();

            return instance;

        }

    }

}

  1. Factory

  2. Abstract Factory

  3. Singleton

  4. Builder

17Feb/100

ASP.NET Interview Questions: Query Strings

A query string is information sent to the server appended to the end of a page URL.
Following are the benefits of using query string for state management:-
. No server resources are required. The query string containing in the HTTP requests for a specific URL.
. All browsers support query strings.
Following are limitations of query string:-
. Query string data is directly visible to user thus leading to security problems.-
. Most browsers and client devices impose a 255-character limit on URL length.
Below is a sample "Login" query string passed in URL http://www.jack-fx.com.com/login.asp?login=testing.
This query string data can then be requested later by using Request.QueryString("login").

(I) What is Absolute and Sliding expiration?

Absolute Expiration allows you to specify the duration of the cache, starting from the time the cache is activated. The following example shows that the cache has a cache dependency specified, as well as an expiration time of one minute.

Cache. Insert ("announcement", announcement, depends, _
DateTime.Now.AddMinutes(1), Nothing)

Sliding Expiration specifies that the cache will expire if a request is not made within a specified duration. Sliding expiration policy is useful whenever you have a large number of items that need to be cached, because this policy enables you to keep only the most frequently accessed items in memory. For example, the following code specifies that the cache will have a sliding duration of one minute. If a request is made 59 seconds after the cache is accessed, the validity of the cache would be reset to another minute:

Cache.Insert("announcement", announcement, depends, _
Date Time. Max Value, _
TimeSpan.FromMinutes(1))

31Dec/090

Core Java Interview Questions

    1. Why the container does not support multiple layout managers
    2. Which class is the super class for all classes in java.lang package?
    3. What are differences between Enumeration, ArrayList, Hashtable and Collections and
    4. How many JVM could be run on an operating system. if only one then what is the logical reason.
    5. What is JVM Heap Size? How does it affect the performance of the Application?
    6. We know that Object class is super class of every class & a class extends only one class. so How is it possible to a class to extend other than Object class?
    7. What is difference between string and stringtokenizer?
    8. How can you load DLL files when your java class is loading first time ?
    9. If two overloaded methods are - test(Object xyz) and test(Customer cust) [Assume Customer is a class with member name of type String]. Now if we call test(null), which method will be called? why?
    10. When are you using arraylist and linkedlist?
    11. When are you using hashmap and hashtable?
    12. Can we have run() method directly without start() method in threads?
    13. How to use JNI in Java? What are Struts and Jini? How to apply native code in Java?
    14. Can we have run() method directly without start() method in threads?
    15. How to use JNI in java? and what are Struts and jini?and how to apply native code in java?
    16. Strings are immutable.But String s="Hello"; String s1=s+"World"; S.O.P(s1); means printing "HelloWorld". How ?
    17. What is the difference between classpath and path variable?
    18. If we have two public classes in a single java file, How I have to give the name of the particular java file and How I can compile it?
    19. Is there any difference between Execution Engine and the JIT in java?
    20. How single threaded model works after implementation in class, basically architecture point of view?
29Dec/091

C# interview questions

    1. What’s the advantage of using System.Text.StringBuilder over System.String? StringBuilder 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.
    2. Can you store multiple data types in System.Array? No.
    3. 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.
    4. How can you overload a method? Different parameter data types, different number of parameters, different order of parameters.
    5. 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. What’s the difference between System.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.
    7. What’s a delegate? A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.
    8. What’s a multicast delegate? It’s a delegate that points to and eventually fires off several methods.

More: http://tipsinterview.com/doc/Csharp_Interview_Questions.doc

21Dec/090

Basic interview questions for C# Component Developers

    1. Explain the differences between public, protected, private and internal.
    2. What benefit do you get from using a Primary Interop Assembly (PIA)?
    3. By what mechanism does NUnit know what methods to test?
    4. What is the difference between typeof(foo) and myFoo.GetType()?
    5. Explain what’s happening in the first constructor: public class c{ public c(string a) : this() {;}; public c() {;} } How is this construct useful?
    6. What is this? Can this be used within a static method?
    7. Explain the importance and use of each component of this string: Foo.Bar, Version=2.0.205.0, Culture=neutral, PublicKeyToken=593777ae2d274679d
    8. What is the difference between: catch(Exception e){throw e;} and catch(Exception e){throw;}
    9. Juxtapose the use of override with new. What is shadowing?
    10. Explain the use of virtual, sealed, override, and abstract.