cSharp

28
C# Questions 1. Which one of the following is NOT one of the types of deployment projects? a.) Web Setup b.) Merge Module c.) Remote Machine d.) Cab e.) Setup 2. Dim A As Integer = 10 Dim B As Integer = 8 Dim C As Integer = 6 Dim myCheck As Boolean Given the code above, what expression sets myCheck to true? Choice 1 myCheck = B > A Xor C > B Choice 2 myCheck = A > B Xor B > C Choice 3 myCheck = B < A Xor C < B Choice 4 myCheck = B > A Xor B > C Choice 5 myCheck = A > C Xor B > C 3. Protected Sub TestSub () Dim NewClass as New TestClass() NewClass.ThisProperty = 15 MsgBox (NewClass.ThisProperty) End Sub Public Class TestClass Public ThisField as Integer Private var1 = 0 Public Property ThisProperty() as Integer Get return var1 1

Transcript of cSharp

Page 1: cSharp

C# Questions

1. Which one of the following is NOT one of the types of deployment projects?

a.) Web Setupb.) Merge Modulec.) Remote Machine d.) Cabe.) Setup

2. Dim A As Integer = 10 Dim B As Integer = 8 Dim C As Integer = 6 Dim myCheck As Boolean Given the code above, what expression sets myCheck to true?

Choice 1 myCheck = B > A Xor C > B Choice 2 myCheck = A > B Xor B > C Choice 3 myCheck = B < A Xor C < B Choice 4 myCheck = B > A Xor B > C Choice 5 myCheck = A > C Xor B > C

3. Protected Sub TestSub () Dim NewClass as New TestClass() NewClass.ThisProperty = 15 MsgBox (NewClass.ThisProperty) End Sub

Public Class TestClass Public ThisField as Integer Private var1 = 0 Public Property ThisProperty() as Integer Get return var1 End Get Set (ByVal var2 as Integer) If var2 < 15 then var1 = var2 End Set End Property End Class What is the value of NewClass.ThisProperty in the above code?

1

Page 2: cSharp

C# Questions

Choice 1 0 Choice 2 2 Choice 3 15 Choice 4 20 Choice 5 25

4. Which one of the following is NOT one of the public methods for the Request Object?

a.) ToStringb.) Equalsc.) GetTyped.) Save e.) GetHashCode

5. Which one of the following standard dialog boxes is valid?

a.) FilePathDialogb.) CloseFileDialogc.) PrinterSetupDialogd.) FontDialog e.) SaveAsFileDialog

6. 1. Private Sub MyFunction(ByRef intCounter As Integer) 2. intCounter += 2 3. 4. End Sub Given the code above, what line of code do you place in Line 3 to display a message "intCounter is Greater than 3" only when intCounter is at a value 4 or higher?

Choice 1 Debug.WriteLineWhen(intCounter > 3, "intCounter is Greater than 3") Choice 2 Debug.PrintWhen(intCounter > 3, "intCounter is Greater than 3") Choice 3 Debug.WriteIf(intCounter > 3, "intCounter is Greater than 3") Choice 4 Debug.PrintIf(intCounter > 3, "intCounter is Greater than 3")

2

Page 3: cSharp

C# Questions

7. Dim custDA As SqlDataAdapter = New SqlDataAdapter("SELECT CustomerID, CompanyName FROM Customers", nwindConn)

'Missing Code Snippet

Private Shared Sub OnRowUpdated(sender As Object, args As SqlRowUpdatedEventArgs) If args.Status = UpdateStatus.ErrorsOccurred args.Status = UpdateStatus.SkipCurrentRow args.Row.RowError = args.Errors.Message End If End Sub Referring to the above code, what line of code below properly adds an event handler to your newly created Data Adapter?

a.) AddHandler custDA.RowUpdated, New SqlOnUpdateEventHandler(VarPtr(OnRowUpdated)) b.) AddHandler custDA.RowUpdated, New SqlRowUpdatedEventHandler(ObjPtr(OnRowUpdated)) c.) AddHandler custDA.RowUpdated, New SqlRowEventHandler(FuncPtr(OnRowUpdated)) d.) AddHandler custDA.RowUpdated, New SqlColRowUpdatedEventHandler(AddressOf CType(Object,OnRowUpdated)) e.) AddHandler custDA.RowUpdated, New SqlRowUpdatedEventHandler(AddressOf OnRowUpdated)

8. What object does SQL Connection use to make security demands?

a.) SQLPermissionClientb.) SQLClientPermission c.) SQLPermissiond.) SQLClientPermissionAttributee.) SQLClientAttribute

9. If you drag SQL Server nodes from server explorer onto Visual Basic .NET designers, what happens?

a.) Server Explorer automatically creates controls that must be configured to reference the item dropped.b.) Server Explorer automatically creates controls that are preconfigured to reference the item dropped.c.) Server Explorer automatically creates data components that are preconfigured to reference the item dropped. d.) Server Explorer automatically creates new data components whose references must be custom configured.e.) Server Explorer automatically creates data components that must be configured to reference the item dropped.

3

Page 4: cSharp

C# Questions

10. Public MustInherit Class Shape Public Sub New() Console.WriteLine("Creating a Shape Objects") End Sub Public Overridable-Blank1 Sub Draw() Console.WriteLine("I am a Shape") End SubEnd ClassPublic Class Circle Inherits-Blank2 Shape Public Sub New() Console.WriteLine("Creating a Circle Objects") End Sub Public Overrides-Blank3 Sub Draw() Console.WriteLine("I am a Circle") MyBase.Draw()-Blank4 End SubEnd Class

Module Module1

Sub Main() Dim c As New Circle() c.Draw() Console.ReadLine() End Sub

End Module

a.) BLANK1 = OverridableBLANK2 = ImplementsBLANK3 = OverridesBLANK4 = Super.Draw()b.) BLANK1 = Overridable BLANK2 = InheritsBLANK3 = OverridesBLANK4 = MyBase.Draw()c.) BLANK1 = OverridableBLANK2 = MustInheritBLANK3 = OverridesBLANK4 = Me.Draw()d.) BLANK1 = ImplementableBLANK2 = InheritsBLANK3 = Overriding

4

Page 5: cSharp

C# Questions

BLANK4 = Me.Draw()e.) BLANK1 = OverridableBLANK2 = ImplementsBLANK3 = OverridesBLANK4 = MyBase.Draw()

11. Public Class TestClass Public Sub Setup() MsgBox("HI") End Sub End ClassReferring to the above sample, what specific type of member is the method Setup in relation to the class TestClass? a.) Overridden Memberb.) Protected Memberc.) Shared Member d.) Instance Membere.) Shadow Member

12. Within the Command Window, what is the difference between the purpose of Command Mode and Immediate Mode?

a.) Immediate Mode allows you to execute commands that do not appear in any menu; Command Mode does not.b.) Command Mode is used for evaluating variable values, executing statements, and printing variable values; Immediate Mode is used for executing commands or aliases directly in the environment and for executing commands not in any menu.c.) Command Mode and Immediate Mode have the same purpose.d.) Command Mode is used for evaluating expressions, executing statements, and printing variable values; Immediate Mode is used for executing commands or aliases directly in the environment and for executing commands not in any menu.e.) Command Mode is used for executing commands or aliases directly in the environment and executing commands not in any menu; the Immediate Window is used for evaluating expressions, executing statements, and printing variable values.

13. What type of declarative notation does DataBinding use?

a.) <%# %> b.) <% #%>c.) <%$ %>d.) <% %>e.) <% %$>

14. What is the Global Assembly Cache?

5

Page 6: cSharp

C# Questions

a.) The Global Assembly Cache is a complex term for a simple concept; it is the place where all the tools in the Visual Basic .NET tool box reside.b.) The Global Assembly Cache is a special spot in memory in which programmers are encouraged to store their global program variables.c.) The Global Assembly Cache is a machine-wide code cache. d.) The Global Assembly Cache is vast stores of Microsoft Provided Programming Tools that programmer are able to consume to enrich their own program.e.) The Global Assembly Cache is a special system folder similar to the Recycle Bin.

15. Which one of the following is NOT one of the public methods for the Request Object?

a.) ToStringb.) Equalsc.) GetTyped.) Save e.) GetHashCode

16. What is the purpose of an HTML server control?

a.) To provide an object model that ignores the effects of client side script on itb.) To provide an object model that eliminates any use of custom attributesc.) To provide an object model that bars automatic maintenanced.) To provide an object model that you can program against on the server using object-oriented methods e.) To provide HTML elements as text that passes straight through the server to the browser as text, thereby increasing efficiency

17. What interface and associated method pair must a class implement in order to allow standard sorting in an Array?

Choice 1 Interface: IComparable Method: CompareTo() Choice 2 Interface: IComparer Method: IsComparable() Choice 3 Interface: IComparable Method: Compare() Choice 4 Interface: IComparer Method: Compare()

18. What is the purpose of the ToString method of the Request object?

6

Page 7: cSharp

C# Questions

Choice 1 To return a string that represents the current object Choice 2 To write a string to the browser window Choice 3 To convert a string into a number Choice 4 To convert a numeric variable into a string Choice 5 To return a reference number that represents the current object within a collection

19. Which one of the following is NOT true regarding the new ADO.NET DataReader?

Choice 1 Using the DataReader can increase application performance and reduce system overhead because only one row at a time is ever in memory. Choice 2 You can use the DataReader to retrieve a read-only, forward-only stream of data from a database. Choice 3 The DataReader is an efficient choice when retrieving large amounts of data because the data is not cached in memory. Choice 4 DataReaders are an excellent way to pool your connections. Since they are fast and efficient by design, you can connect up to ten DataReaders to one database connection object. Choice 5 The DataReader provides an unbuffered stream of data that allows procedural logic to efficiently process results from a data source sequentially.

20. What is the purpose of Tracing?

Choice 1 To record the history of the value changes a certain variable goes through in execution Choice 2 To monitor the execution of your application while it is running by recording information about errors and application execution to logs, text files, or other devices for later analysis Choice 3 To monitor your application while it is compiling by recording information about errors to an immediate dialog box Choice 4 To monitor the execution of your application while it is running by displaying information in an immediate dialog box Choice 5

7

Page 8: cSharp

C# Questions

To monitor the compilation of your application

21. If you would like to bind a multi-record control to a dataset, to which property do you set the name of the table to bind?

Choice 1 DataValue Choice 2 DataMember Choice 3 DataTable Choice 4 DataSource Choice 5 DataBind

22. In which one of the following is a function NOT defined?

Choice 1 Inside a class Choice 2 Inside a structure Choice 3 Inside another function Choice 4 Inside an interface Choice 5 Inside a module

23. Which one of the following statements concerning polymorphism is true? Choice 1 Polymorphism provides for single implementations of abstract classes. Choice 2 Polymorphism provides for multiple implementations of different subclass methods through one super class instantiation. Choice 3 Polymorphism provides for multiple methods of the same class instantiation. Choice 4 Polymorphism provides for multiple inheritance of abstract classes. Choice 5 Polymorphism provides for single implementations of a base method.

24. DataGrid1.SetDataBinding(DsCustomers1, "Customers") What is the purpose of the above code?

8

Page 9: cSharp

C# Questions

A. To fill a DataGrid control from the Customers table within a dataset named DsCustomers1 B. To bind a DataGrid control to both the Customers and DsCustomers1 tables C. To fill a DataGrid control from two tables: Customers and DsCustomers1 D. To fill a DataGrid control from the DsCustomers1 table within a dataset named Customers E. To bind a DataGrid control to the Customers table within a dataset named DsCustomers1

25. Public Class Car Shared CarCount As Integer

Public Function Count() As Integer Return CarCount End Function

Public Sub New() CarCount += 1 Tire.TireCount += 4 End Sub

Public Class Tire Public Shared TireCount As Integer End Class End Class

Module MyApp Public Sub Main() Dim c1 As Car Dim c2 As Car c1.Count() c2.Count() Console.Write(Car.CarCount.ToString()) Console.Write(Car.Tire.TireCount.ToString()) End Sub End Module

What is WRONG with the code above?

Choice 1 Car.Tire.TireCount cannot be accessed as it is currently defined. Choice 2 Car.CarCount cannot be accessed as it is currently defined. Choice 3 An internal class cannot be declared as public. Choice 4 Car.Tire.TireCount should be referenced as simply Tire.TireCount

9

Page 10: cSharp

C# Questions

Choice 5 One class cannot be defined within another class.

26. Which one of the following statements is true about Public Key Cryptography?

Choice 1 Public-key algorithms are known as asymmetric algorithms. Choice 2 Public-key encryption is meant for a large amount of data. Choice 3 Public-key encryption uses a dynamic buffer size. Choice 4 A public key must be secured. Choice 5 A public key is extremely fast.

27. Which one of the following is NOT true regarding Out-Of-Process (OOP) .NET Components? Choice 1 Windows loads OOP components in a separate process space that is created for the component. Windows also manages the out-of-process component's resource requirements independently of the client application. Choice 2 OOP components tend to run faster than In-Process components because remote procedure calls are not necessary. The client application has direct access to the component, making communication much more efficient. Choice 3 OOP applications may, in some cases, prove to be more stable than applications built from in-process components. If an OOP component crashes, it does not take the consumer application with it; this is not always the case with In-Process objects. Choice 4 some performance degradation can occur in OOP applications if the component is simultaneously requested by a large number of consumers. Choice 5 OOP components are more easily shared among a number of consumer applications. When compiled as sharable resources, Windows loads a single copy of an out-of-process component and makes it available to as many consumers as request it.

28. What must be in place before a control can be created dynamically? Choice 1 A PlaceSpotter control Choice 2 A PlaceMarker control Choice 3 A Literal Web Server control

10

Page 11: cSharp

C# Questions

Choice 4 A Holder Choice 5 A Container

29. Which one of the following is NOT a data type conversion function? Choice 1 CByte Choice 2 CStr Choice 3 CNum Choice 4 CLng Choice 5 CShort 30. textBoxID.DataBindings.Add( Arg1, Arg2, Arg3 ) Referring to the sample code above, what are the names of the parameters assigned to the add method of the DataBindings collection within the text box?

Choice 1 PropertyStatus, DataSource, DataBindingMethod Choice 2 PropertyName, DataSource, DataStatus Choice 3 PropertyName, DataSource, DataMember Choice 4 PropertyBag, DataBindingMethod, DataMember Choice 5 PropertyBag, DataSource, DataMember

31. Public Class BaseTax Private Const CountyRate As Double = 0.053 ' %5.3 State tax Friend Const LocalRate As Double = 0.028 ' %2.8 City tax

Overridable Function FigureTax(ByVal Amount As Double) As Double Return Amount * CountyRate ' Calculate state tax. End Function End Class

Public Class LocalTax Inherits BaseTax Private BaseAmount As Double Overrides Function FigureTax(ByVal Amount As Double) As Double ' Some cities apply a tax to the total cost of purchases,

11

Page 12: cSharp

C# Questions

' including other taxes. BaseAmount = MyBase.FigureTax(Amount) Return LocalRate * (BaseAmount + Amount) + BaseAmount End Function End Class Given the above code sample, what must be done to implement LocalTax polymorphically? Choice 1 Dim Item1 As New BaseTax(New LocalTax()) Choice 2 Dim Item1 As New MyBase.LocalTax() Choice 3 Dim Item1 As New BaseTax(Morph LocalTax()) Choice 4 Dim Item2 As New LocalTax() Choice 5 Dim Item1 As New BaseTax() Dim Item2 As New LocalTax() Item1 = Item2

32. 1. Private Sub MyFunction(ByRef intCounter As Integer) 2. intCounter += 2 3. 4. End Sub Given the code above, what line of code do you place in Line 3 to display a message "intCounter is Greater than 3" only when intCounter is at a value 4 or higher? Choice 1 Debug.WriteLineWhen(intCounter > 3, "intCounter is Greater than 3") Choice 2 Debug.PrintWhen(intCounter > 3, "intCounter is Greater than 3") Choice 3 Debug.WriteIf(intCounter > 3, "intCounter is Greater than 3") Choice 4 Debug.PrintIf(intCounter > 3, "intCounter is Greater than 3") Choice 5 Debug.WriteWhen(intCounter > 3, "intCounter is Greater than 3")

33. What is a satellite Assembly?

A) Any DLL file used by an EXE file.B) An assembly containing localized resources for another assembly.C) An assembly designed to alter the appearance or ‘skin’ of an application.D) A peripheral assembly designed to monitor permissions requests from an application.

34. By what file name extension are Web User Controls identified?

12

Page 13: cSharp

C# Questions

A. .ascu B. .ascx C. .aspu D. .asca E. .aspx

35. In a data adapter, if you are using a SQL Connection object, from which class do your commands need to be derived?

A. SQLCommand B. SQLDbCommand C. OleSQLCommand D. DbCommand E. OleDbCommand

36. With which one of the following Visual Basic .NET windows forms controls can you use data binding?

A. TextBox, ListSet, DataSet, DataGrid, ComboBox B. TextGrid, ListBox, DataSet, DataGrid, ComboBox C. TextBox, ListBox, DataSet, DataGrid, ComboBox D. TextBox, ListBox, DataSet, DataBox, ComboBox E. TextBox, ImageList, DataSet, DataGrid, ComboBox

37. Which one of the following is NOT a valid Windows Control?

A. ProgressBar B. ButtonControl C. ImageList D. MainMenu E. DebugIcon

Below is the list of conversion functions which we can use in VB .NET.

CBool - use this function to convert to Bool data typeCByte - use this function to convert to Byte data typeCChar - use this function to convert to Char data typeCDate - use this function to convert to Date typeCDbl - use this function to convert to Double data typeCDec - use this function to convert to Decimal data typeCInt - use this function to convert to Integer data typeCLng - use this function to convert to Long data typeCObj - use this function to convert to Object typeCShort - use this function to convert to Short data type

13

Page 14: cSharp

C# Questions

CSng - use this function to convert to Single data typeCString - use this function to convert to String data type

HTML Server Controls Futures

HTML server controls are HTML elements (or elements in other supported markup, such as XHTML) containing attributes that make them programmable in server code. By default, HTML elements on an ASP.NET Web page are not available to the server. Instead, they are treated as opaque text and passed through to the browser. However, by converting HTML elements to HTML server controls, you expose them as elements you can program on the server.The object model for HTML server controls maps closely to that of the corresponding elements. For example, HTML attributes are exposed in HTML server controls as properties.Any HTML element on a page can be converted to an HTML server control by adding the attribute runat="server". During parsing, the ASP.NET page framework creates instances of all elements containing the runat="server" attribute. If you want to reference the control as a member within your code, you should also assign an id attribute to the control.The page framework provides predefined HTML server controls for the HTML elements most commonly used dynamically on a page: the form element, the input elements (text box, check box, Submit button), the select element, and so on. These predefined HTML server controls share the basic properties of the generic control, and in addition, each control typically provides its own set of properties and its own event.HTML server controls offer the following features:

An object model that you can program against on the server using familiar object-oriented techniques. Each server control exposes properties that enable you to manipulate the control's markup attributes programmatically in server code.

A set of events for which you can write event handlers in much the same way you would in a client-based form, except that the event is handled in server code.

The ability to handle events in client script. Automatic maintenance of the control's state. When the page makes a round trip to the

server, the values that the user entered into HTML server controls are automatically maintained and sent back to the browser.

Interaction with ASP.NET validation controls so you can verify that a user has entered appropriate information into a control.

Data binding to one or more properties of the control. Support for styles if the ASP.NET Web page is displayed in a browser that supports

cascading style sheets. Pass-through of custom attributes. You can add any attributes you need to an HTML

server control and the page framework will render them without any change in functionality. This enables you to add browser-specific attributes to your controls.

Web Server Controls Futures

Web server controls are a second set of controls designed with a different emphasis. They do not necessarily map one-to-one to HTML server controls. Instead, they are defined as abstract controls in which the actual markup rendered by the control can be quite different from the

14

Page 15: cSharp

C# Questions

model that you program against. For example, a RadioButtonList Web server control might be rendered in a table or as inline text with other markup.Web server controls include traditional form controls such as buttons and text boxes as well as complex controls such as tables. They also include controls that provide commonly used form functionality such as displaying data in a grid, choosing dates, displaying menus, and so on.Web server controls offer all of the features described above for HTML server controls (except one-to-one mapping to elements) and these additional features:

A rich object model that provides type-safe programming capabilities. Automatic browser detection. The controls can detect browser capabilities and render

appropriate markup. For some controls, the ability to define your own layout for the control using

Templates(). For some controls, the ability to specify whether a control's event causes immediate

posting to the server or is instead cached and raised when the page is submitted. Support for themes, which enable you to define a consistent look for controls throughout

your site. For details, see ASP.NET Themes and Skins. Ability to pass events from a nested control (such as a button in a table) to the container

control.The controls use syntax such as the following:Copy<asp:button attributes runat="server" id="Button1" />The attributes in this case are not those of HTML elements. Instead, they are properties of the Web control.When the ASP.NET Web page runs, the Web server control is rendered on the page using appropriate markup, which often depends not only on the browser type but also on settings that you have made for the control. For example, a TextBox control might render as an input tag or a textarea tag, depending on its properties.

Polymorphism in Components

Polymorphism is the ability for classes to provide different implementations of methods that are called by the same name. Polymorphism allows a method of a class to be called without regard to what specific implementation it provides. For example, you might have a class named Road which calls the Drive method of an additional class. This Car class may be SportsCar, or SmallCar, but both would provide the Drive method. Though the implementation of the Drive method would be different between the classes, the Road class would still be able to call it, and it would provide results that would be usable and interpretable by the Road class.Polymorphism in components can be implemented in a variety of ways:

Interface polymorphism - Multiple classes may implement the same interface, and a single class may implement one or more interfaces. Interfaces are essentially definitions of how a class needs to respond. An interface describes the methods, properties, and events that a class needs to implement, and the type of parameters each member needs to receive and return, but leaves the specific implementation of these members up to the implementing class.

15

Page 16: cSharp

C# Questions

Inheritance polymorphism - Multiple classes may inherit from a single base class. By inheriting, a class receives all of the methods, properties, and events of the base class in the same implementation as the base class. Additional members can then be implemented as needed, and base members can be overridden to provide different implementations. Note that an inherited class may also implement interfaces — the techniques are not mutually exclusive.

Polymorphism through abstract classes - Abstract classes provide elements of both inheritance and interfaces. An abstract class is a class that cannot be instantiated itself; it must be inherited. Some or all members of the class might be unimplemented, and it is up to the inheriting class to provide that implementation. Members that are implemented might still be overridden, and the inheriting class can still implement addition interfaces or other functionality.

These three types of polymorphism are discussed in greater detail below.Interface PolymorphismA powerful technique in component programming is being able to implement multiple interfaces on an object. Each interface is composed of a small group of closely related methods, properties, and events. By implementing interfaces, your component can provide functionality to any other component requiring that interface, without regard to the particular functionality contained within. This allows successive versions of components to incorporate different capability without disturbing core functionality.The features of your component most commonly used by other developers should naturally be members of the component class itself. However, components with a large number of members can be difficult to use. Consider factoring out some features of your component as separate interfaces that are implemented privately.Another benefit of defining features in terms of interfaces is that you can add features to your component incrementally by defining and implementing additional interfaces. Advantages include:

Design effort is simplified, because components can begin small, with minimal functionality, and continue to provide that functionality while acquiring additional features over time, as it becomes clear from actual use what those features should be.

Maintaining compatibility is simplified, because new versions of a component can continue to provide existing interfaces, while adding new interfaces. Subsequent versions of client applications can take advantage of these when it makes sense for them to do so.

Polymorphism Through InheritanceVisual Basic and C# also provide polymorphism through inheritance. This is a powerful mechanism for small-scale development tasks, but has generally proven to be problematic for large-scale systems. An over-emphasis on inheritance-driven polymorphism typically results in a massive shift of resources from coding to designing, which does nothing to shorten overall development time. Given that the real test of software is whether it works for end users, tools for rapid prototyping and rapid application development (RAD) have gained wider acceptance than tools for object-oriented programming.

When to Use Inheritance-Driven Polymorphism

16

Page 17: cSharp

C# Questions

The foremost use of inheritance is to add functionality to an existing base class. Programmer productivity is much greater when you start with a framework of fully debugged base classes, and methods can be incrementally added to base classes without breaking versioning.You may also wish to use inheritance when your application design includes several related classes that must share identical implementation for certain common functions. The overlapping functionality can be implemented in a base class, from which the classes used in the application can be derived. An abstract class combines features of both inheritance and implementation, and may be useful when elements of each are needed.Polymorphism Through Abstract ClassesAbstract classes provide features of both inheritance and interface implementation. An abstract (MustInherit in Visual Basic) class is a class that cannot be instantiated, and must be implemented in an inheriting class. It may contain methods and properties that are already implemented, but it may also incorporate unimplemented procedures which must be implemented in the inheriting class. This allows you to provide an invariant level of functionality in some methods of your class, while leaving flexibility options open for other procedures. An additional benefit of abstract classes is that when new versions of your component are required, additional methods may be added to the base class as needed, whereas interfaces must remain invariant.When to Use Abstract ClassesAn abstract class is useful when you need a group of related components to incorporate a set of methods with identical functionality, but also require flexibility in the implementation of other methods. Abstract classes are also valuable when versioning issues are anticipated, because the base class remains flexible and easily modified.

JavaScript interview questions and answers

1. What’s relationship between JavaScript and ECMAScript? ECMAScript is yet another name for JavaScript (other names include LiveScript). The current JavaScript that you see supported in browsers is ECMAScript revision 3.2. What are JavaScript types?Number, String, Boolean, Function, Object, Null, Undefined.3. How do you convert numbers between different bases in JavaScript? Use the parseInt() function, that takes a string as the first parameter, and the base as a second parameter. So to convert hexadecimal 3F to decimal, use parseInt ("3F", 16);4. What does isNaN function do? Return true if the argument is not a number.5. What is negative infinity? It’s a number in JavaScript, derived by dividing negative number by zero.6. What Boolean operators does JavaScript support? &&, || and !7. What does "1"+2+4 evaluate to? Since 1 is a string, everything is a string, so the result is 124.8. How about 2+5+"8"? Since 2 and 5 are integers, this is number arithmetic, since 8 is a string, it’s concatenation, so 78 is the result.

17

Page 18: cSharp

C# Questions

9. What looping structures are there in JavaScript? for, while, do-while loops, but no foreach.10. How do you create a new object in JavaScript?var obj = new Object(); or var obj = {};11. How do you assign object properties? obj["age"] = 17 or obj.age = 17.12. What’s a way to append a value to an array? arr[arr.length] = value;13. What is this keyword? It refers to the current object.

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 sort the elements of the array in descending order? By calling Sort() and

then Reverse() methods.5. What’s the .NET datatype that allows the retrieval of data by a unique key? HashTable.6. What’s class SortedList underneath? A sorted HashTable.7. Will finally block get executed if the exception had not occurred? Yes.8. 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 {}.

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

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

11. What’s a delegate? A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.

12. What’s a multicast delegate? It’s a delegate that points to and eventually fires off several methods.

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

14. What are the ways to deploy an assembly? An MSI installer, a CAB archive, and XCOPY command.

18

Page 19: cSharp

C# Questions

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

16. What namespaces are necessary to create a localized application? System.Globalization, System.Resources.

17. What’s the difference between // comments, /* */ comments and /// comments? Single-line, multi-line and XML documentation comments.

18. How do you generate documentation from the C# file commented properly with a command-line compiler? Compile it with a /doc switch.

19. What’s the difference between <c> and <code> XML documentation tag? Single line code example and multiple-line code example.

20. Is XML case-sensitive? Yes, so <Student> and <student> are different elements.21. 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.

22. What does the This window show in the debugger? It points to the object that’s pointed to by this reference. Object’s instance data is shown.

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

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

25. 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 risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing to fine-tune the tracing activities.

26. Where is the output of TextWriterTraceListener redirected? To the Console or a text file depending on the parameter passed to the constructor.

27. How do you debug an ASP.NET Web application? Attach the aspnet_wp.exe process to the DbgClr debugger.

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

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

30. Explain the three services model (three-tier application). Presentation (UI), business (logic and underlying code) and data (from storage or other sources).

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

19

Page 20: cSharp

C# Questions

32. What’s the role of the DataReader class in ADO.NET connections? It returns a read-only dataset from the data source when the command is executed.

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

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

35. What connections does Microsoft SQL Server support? Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords).

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

37. Why would you use untrusted verificaion? Web Services might use it, as well as non-Windows applications.

38. What does the parameter Initial Catalog define inside Connection String? The database name to connect to.

39. What’s the data provider name to connect to Access database? Microsoft.Access.40. What does Dispose method do with the connection object? Deletes it from the memory.41. 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.

20