Saturday, April 24, 2010

Basic Java Interview Questions

Basic Java Interview Questions

Question 1 : What is the difference between an Interface and an Abstract class?

A: An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation. An abstract class is a class which may have the usual flavors of class members (private, protected, etc.), but has some abstract methods.

Question 2: What is the purpose of garbage collection in Java, and when is it used?

A: The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused. A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used.

Question 3: Describe synchronization in respect to multithreading.

A: With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchonization, it is possible for one thread to modify a shared variable while another thread is in the process of using or updating same shared variable. This usually leads to significant errors.

Question 4: Explain different way of using thread?

A: The thread could be implemented by using runnable interface or by inheriting from the Thread class. The former is more advantageous, 'cause when you are going for multiple inheritance..the only interface can help.

Question 5 : What are pass by reference and passby value?

A: Pass By Reference means the passing the address itself rather than passing the value. Passby Value means passing a copy of the value to be passed.

Question 6: What is HashMap and Map?

A: Map is Interface and Hashmap is class that implements that.

Question 7: Difference between HashMap and HashTable?

A: The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls. (HashMap allows null values as key and value whereas Hashtable doesnt allow). HashMap does not guarantee that the order of the map will remain constant over time. HashMap is unsynchronized and Hashtable is synchronized.

Question 8: Difference between Vector and ArrayList?

A: Vector is synchronized whereas arraylist is not.

Question 9: Difference between Swing and Awt?

A: AWT are heavy-weight componenets. Swings are light-weight components. Hence swing works faster than AWT.

Question 10: What is the difference between a constructor and a method?

A: A constructor is a member function of a class that is used to create objects of that class. It has the same name as the class itself, has no return type, and is invoked using the new operator.A method is an ordinary member function of a class. It has its own name, a return type (which may be void), and is invoked using the dot operator.

Question 11: What is an Iterator?

A: Some of the collection classes provide traversal of their contents via a java.util.Iterator interface. This interface allows you to walk through a collection of objects, operating on each object in turn. Remember when using Iterators that they contain a snapshot of the collection at the time the Iterator was obtained; generally it is not advisable to modify the collection itself while traversing an Iterator.

Question 12: State the significance of public, private, protected, default modifiers both singly and in combination and state the effect of package relationships on declared items qualified by these modifiers.

A: public : Public class is visible in other packages, field is visible everywhere (class must be public too)


private : Private variables or methods may be used only by an instance of the same class that declares the variable or method, A private feature may only be accessed by the class that owns the feature.


protected : Is available to all classes in the same package and also available to all subclasses of the class that owns the protected feature.This access is provided even to subclasses that reside in a different package from the class that owns the protected feature.


default :What you get by default ie, without any access modifier (ie, public private or protected).It means that it is visible to all within a particular package
.

Question 13: What is an abstract class?

A: Abstract class must be extended/subclassed (to be useful). It serves as a template. A class that is abstract may not be instantiated (ie, you may not call its constructor), abstract class may contain static data. Any class with an abstract method is automatically abstract itself, and must be declared as such.
A class may be declared abstract even if it has no abstract methods. This prevents it from being instantiated.

Question 14: What is static in java?

A: Static means one per class, not one for each object no matter how many instance of a class might exist. This means that you can use them without creating an instance of a class.Static methods are implicitly final, because overriding is done based on the type of the object, and static methods are attached to a class, not an object. A static method in a superclass can be shadowed by another static method in a subclass, as long as the original method was not declared final. However, you can't override a static method with a nonstatic method. In other words, you can't change a static method into an instance method in a subclass.

Question 15: What is final?

A: A final class can't be extended ie., final class may not be subclassed. A final method can't be overridden when its class is inherited. You can't change value of a final variable (is a constant).

Question 16: What are Checked and UnChecked Exception?

A: A checked exception is some subclass of Exception (or Exception itself), excluding class RuntimeException and its subclasses.Making an exception checked forces client programmers to deal with the possibility that the exception will be thrown. eg, IOException thrown by java.io.FileInputStream's read() method· Unchecked exceptions are RuntimeException and any of its subclasses. Class Error and its subclasses also are unchecked. With an unchecked exception, however, the compiler doesn't force client programmers either to catch the exception or declare it in a throws clause. In fact, client programmers may not even know that the exception could be thrown. eg, StringIndexOutOfBoundsException thrown by String's charAt() method· Checked exceptions must be caught at compile time. Runtime exceptions do not need to be. Errors often cannot be.

Question 17: What is Overriding?

A: When a class defines a method using the same name, return type, and arguments as a method in its superclass, the method in the class overrides the method in the superclass. When the method is invoked for an object of the class, it is the new definition of the method that is called, and not the method definition from superclass. Methods may be overridden to be more public, not more private.

Question 18: What are different types of inner classes?

A: Nested top-level classes, Member classes, Local classes, Anonymous classes

Nested top-level classes- If you declare a class within a class and specify the static modifier, the compiler treats the class just like any other top-level class.
Any class outside the declaring class accesses the nested class with the declaring class name acting similarly to a package. eg, outer.inner. Top-level inner classes implicitly have access only to static variables.There can also be inner interfaces. All of these are of the nested top-level variety.

Member classes - Member inner classes are just like other member methods and member variables and access to the member class is restricted, just like methods and variables. This means a public member class acts similarly to a nested top-level class. The primary difference between member classes and nested top-level classes is that member classes have access to the specific instance of the enclosing class.

Local classes - Local classes are like local variables, specific to a block of code. Their visibility is only within the block of their declaration. In order for the class to be useful beyond the declaration block, it would need to implement a
more publicly available interface.Because local classes are not members, the modifiers public, protected, private, and static are not usable.

Anonymous classes - Anonymous inner classes extend local inner classes one level further. As anonymous classes have no name, you cannot provide a constructor.

Core Java Objective Gyan-1 ;

Q 01: What is Test Driven Development (TDD)?

Q 02: What is the point of Test Driven Development (TDD)? What do you think of TDD?

03: What is aspect oriented programming (AOP)? Do you have any experience with

Q 04: What are the differences between OOP and AOP?

Q 05: What are the benefits of AOP?

Q 06: What is attribute or annotation oriented programming?

Q 07: What are the pros and cons of annotations over XML based deployment descriptors?

Q 08: What is XDoclet?

Q 09: What is inversion of control (IoC) (also known more specifically as dependency injection)?

Q 10: What are the different types of dependency injections?

; ;

Q 11: What are the benefits of IoC (aka Dependency Injection)?

Q 12: What is the difference between a service locator pattern and an inversion of control pattern?

Q 13: Why dependency injection is more elegant than a JNDI lookup to decouple client and the service?

Q 14: Explain Object-to-Relational (O/R) mapping?

Q 15: Give an overview of hibernate framework?

Q 16: Explain some of the pitfalls of Hibernate and explain how to avoid them? Give some tips on Hibernate best practices?

Q 17: Give an overview of the Spring framework? What are the benefits of Spring framework?

Q 18: How would EJB 3.0 simplify your Java development compared to EJB 1.x, 2.x ?

Q 19: Briefly explain key features of the JavaServer Faces (JSF) framework?

Q 20: How would the JSF framework compare with the Struts framework? How would a Spring MVC framework compare

with Struts framework?___________________________________________________________________________________

CPP Subjective Type.....

1 Explan what is meant by Protected. When a class is being inherited when the base class constructor and destructor called.

2 Illustrate the concept of polymorphism with example.

3 Explain the concept of data hiding in class.

4 What is meant by Virtual base class.

5 Difference between "C structure" and "C++ structure".

6 Diffrence between a "assignment operator" and a "copy constructor"

8 What is the difference between "overloading" and "overridding"?

9 Explain the need for "Virtual Destructor".

10 Can we have "Virtual Constructors"?

; ;

11 What are the different types of polymorphism?

12 What are Virtual Functions? How to implement virtual functions in "C".

13 What are the different types of Storage classes?

‘ ‘

14 What is Namespace?

15 What are the types of STL containers?.

16 Difference between "vector" and "array"?

17 How to write a program such that it will delete itself after exectution?

18 Can we generate a C++ source code from the binary file?

19 What are inline functions?

20 What is "strstream" ?

21 Explain "passing by value", "passing by pointer" and "passing by reference"

22 Have you heard of "mutable" keyword?

23 Is there something that I can do in C and not in C++?

24 What is the difference between "calloc" and "malloc"?

25 What will happen if I allocate memory using "new" and free it using "free" or allocate using "calloc" and free it using "delete"?

; ;

26 Difference between "printf" and "sprintf".

27 What is "map" in STL?

28 When shall I use Multiple Inheritance?

29 Explain working of printf.

30 Talk sometiming about profiling?

31 How to write Multithreaded applications using C++?

32 Write any small program that will compile in "C" but not in "C++"

33 What is Memory Alignment?

34 Why preincrement operator is faster than postincrement?

35 What are the techniques you use for debugging?

36 How to reduce a final size of executable?

37 Give 2 examples of a code optimization.

C++

http://www.indiastudycenter.com/studyguides/cs/objtest/introcpp.asp

How do you find out if a linked-list has an end?
You can find out by using 2 pointers. One of them goes two nodes each time. The second one goes at one nodes each time. If there is a cycle, the one that goes two nodes each time will eventually meet the one that goes slower. If that is the case, then you will know the linked-list is a cycle.

What is the difference between realloc() and free()?
Free subroutine frees a block of memory allocated by the malloc. Undefined results occur if the Pointer parameter is not a valid pointer. If the Pointer parameter is a null value, no action will occur. realloc changes the size of the block of memory pointed to by the Pointer parameter to the number of bytes specified by the Size parameter and returns a new pointer to the block. The pointer specified by the Pointer parameter must have been created with the malloc, calloc, or realloc

What is semaphore?
Semaphore is a special variable, it has two methods: up and down. Semaphore performs atomic operations, which means ones a semaphore is called it can not be inturrupted.

The internal counter (= #ups - #downs) can never be negative. If you execute the “down” method when the internal counter is zero, it will block until some other thread calls the “up” method. Semaphores are use for thread synchronization.

'
'

Is C an object-oriented language?


C is not an object-oriented language, but limited object-oriented programming can be done in C.

Name some major differences between C++ and Java.
C++ has pointers; Java does not. Java is platform-independent; C++ is not. Java has garbage collection; C++ does not. Java does have pointers. In fact all variables in Java are pointers. The difference is that Java does not allow you to manipulate the addresses of the pointer

What is pure virtual function?
A class is made abstract by declaring one or more of its virtual functions to be pure. A pure virtual function is one with an initializer of = 0 in its declaration

In the derived class, which data member of the base class are visible?
In the public and protected sections.

What is a container class? What are the types of container classes?
A container class is a class that is used to hold objects in memory or external storage. A container class acts as a generic holder. A container class has a predefined behavior and a well-known interface. A container class is a supporting class whose purpose is to hide the topology used for maintaining the list of objects in memory. When a container class contains a group of mixed objects, the container is called a heterogeneous container; when the container is holding a group of objects that are all the same, the container is called a homogeneous container

What is polymorphism?
Polymorphism is the idea that a base class can be inherited by several classes. A base class pointer can point to its child class and a base class array can store different child class objects

What is an adaptor class or Wrapper class?
A class that has no functionality of its own. Its member functions hide the use of a third party software component or an object with the non-compatible interface or a non-object-oriented implementation.

What is a Null object?
It is an object of some class whose purpose is to indicate that a real object of that class does not exist. One common use for a null object is a return value from a member function that is supposed to return an object with some specified properties but cannot find such an object.

What is class invariant?
A class invariant is a condition that defines all valid states for an object. It is a logical condition to ensure the correct working of a class. Class invariants must hold when an object is created, and they must be preserved under all operations of the class. In particular all class invariants are both preconditions and post-conditions for all operations or member functions of the class.

What do you mean by Stack unwinding?
It is a process during exception handling when the destructor is called for all local objects between the place where the exception was thrown and where it is caught.

Define precondition and post-condition to a member function.
Precondition: A precondition is a condition that must be true on entry to a member function. A class is used correctly if preconditions are never false. An operation is not responsible for doing anything sensible if its precondition fails to hold. For example, the interface invariants of stack class say nothing about pushing yet another element on a stack that is already full. We say that isful() is a precondition of the push operation. Post-condition: A post-condition is a condition that must be true on exit from a member function if the precondition was valid on entry to that function. A class is implemented correctly if post-conditions are never false. For example, after pushing an element on the stack, we know that isempty() must necessarily hold. This is a post-condition of the push operation.

What are the conditions that have to be met for a condition to be an invariant of the class?
* The condition should hold at the end of every constructor.
* The condition should hold at the end of every mutator (non-const) operation.

What are proxy objects?
Objects that stand for other objects are called proxy objects or surrogates

Name some pure object oriented languages.
Smalltalk, Java, Eiffel, Sather.

What is an orthogonal base class?
If two base classes have no overlapping methods or data they are said to be independent of, or orthogonal to each other. Orthogonal in the sense means that two classes operate in different dimensions and do not interfere with each other in any way. The same derived class may inherit such classes with no difficulty.

What is a dangling pointer?
A dangling pointer arises when you use the address of an object after its lifetime is over. This may occur in situations like returning addresses of the automatic variables from a function or using the address of the memory block after it is freed.

What is "mutable"?
Answer1.
"mutable" is a C++ keyword. When we declare const, none of its data members can change. When we want one of its members to change, we declare it as mutable.

Asp.net 4

1 What is SOAP and how does it relate to XML?

o The Simple Object Access Protocol (SOAP) uses XML to define a protocol for the exchange of information in distributed computing environments. SOAP consists of three components: an envelope, a set of encoding rules, and a convention for representing remote procedure calls. Unless experience with SOAP is a direct requirement for the open position, knowing the specifics of the protocol, or how it can be used in conjunction with HTTP, is not as important as identifying it as a natural application of XML.

2 Can you walk us through the steps necessary to parse XML documents?

o Superficially, this is a fairly basic question. However, the point is not to determine whether candidates understand the concept of a parser but rather have them walk through the process of parsing XML documents step-by-step. Determining whether a non-validating or validating parser is needed, choosing the appropriate parser, and handling errors are all important aspects to this process that should be included in the candidate’s response.

3 What are possible implementations of distributed applications in .NET?

o .NET Remoting and ASP.NET Web Services. If we talk about the Framework Class Library, noteworthy classes are in System.Runtime.Remoting and System.Web.Services.

4 What are the consideration in deciding to use .NET Remoting or ASP.NET Web Services?

o Remoting is a more efficient communication exchange when you can control both ends of the application involved in the communication process. Web Services provide an open-protocol-based exchange of informaion. Web Services are best when you need to communicate with an external organization or another (non-.NET) technology.

5 What’s a proxy of the server object in .NET Remoting?

o It’s a fake copy of the server object that resides on the client side and behaves as if it was the server. It handles the communication between real server object and the client object. This process is also known as marshaling.

6 What are remotable objects in .NET Remoting?

o Remotable objects are the objects that can be marshaled across the application domains. You can marshal by value, where a deep copy of the object is created and then passed to the receiver. You can also marshal by reference, where just a reference to an existing object is passed.

7 What are channels in .NET Remoting?

o Channels represent the objects that transfer the other serialized objects from one application domain to another and from one computer to another, as well as one process to another on the same box. A channel must exist before an object can be transferred.

8 What security measures exist for .NET Remoting in System.Runtime.Remoting?

o None. Security should be taken care of at the application level. Cryptography and other security techniques can be applied at application or server level.

9 What is a formatter?

o A formatter is an object that is responsible for encoding and serializing data into messages on one end, and deserializing and decoding messages into data on the other end.

10 Choosing between HTTP and TCP for protocols and Binary and SOAP for formatters, what are the trade-offs?

o Binary over TCP is the most effiecient, SOAP over HTTP is the most interoperable.

11 What’s SingleCall activation mode used for?

o If the server object is instantiated for responding to just one single request, the request should be made in SingleCall mode.

12 What’s Singleton activation mode?

o A single object is instantiated regardless of the number of clients accessing it. Lifetime of this object is determined by lifetime lease.

13 How do you define the lease of the object?

o By implementing ILease interface when writing the class code.

14 Can you configure a .NET Remoting object via XML file?

o Yes, via machine.config and application level .config file (or web.config in ASP.NET). Application-level XML settings take precedence over machine.config.

15 How can you automatically generate interface for the remotable object in .NET with Microsoft tools?

o Use the Soapsuds tool.

41 Why does the control’s PostedFile property always show null when using HtmlInputFile control to upload files to a Web server?

· This occurs when an enctype="multipart/form-data" attribute is missing in the
tag.



42 How can the focus be set to a specific control when a Web form loads?

· This can be achieved by using client-side script:

document.forms[0].TextBox1.focus ()

The above code will set the focus to a TextBox named TextBox1 when the page loads.

43 How does System.Web.UI.Page’s IsPostBack property work?

· IsPostBack checks to see whether the HTTP request is accompanied by postback data containing a __VIEWSTATE or __EVENTTARGET parameter. If there are none, then it is not a postback.



44 What is WSDL?

· WSDL is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint. Related concrete endpoints are combined into abstract endpoints (services). (Source: www.w3.org)



45 What is UDDI?

· UDDI stands for Universal Description, Discovery, and Integration. It is like an "Yellow Pages" for Web Services. It is maintained by Microsoft, IBM, and Ariba, and is designed to provide detailed information regarding registered Web Services for all vendors. The UDDI can be queried for specific Web Services.





46 Is it possible to generate the source code for an ASP.NET Web service from a WSDL?

· The Wsdl.exe tool (.NET Framework SDK) can be used to generate source code for an ASP.NET web service with its WSDL link.

Example: wsdl /server http://api.google.com/GoogleSearch.wsdl.





47 Why do uploads fail while using an ASP.NET file upload control to upload large files?

· ASP.NET limits the size of file uploads for security purposes. The default size is 4 MB. This can be changed by modifying the maxRequestLength attribute of Machine.config’s element.





48 Describe the difference between inline and code behind.

· Inline code is written along side the HTML in a page. Code-behind is code written in a separate file and referenced by the .aspx page.





49 Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.

· inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension), the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe.





50 Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?

· Valid answers are:

a. A DataSet can represent an entire relational database in memory, complete with tables, relations, and views.

b. A DataSet is designed to work without any continuing connection to the original data source.

c. Data in a DataSet is bulk-loaded, rather than being loaded on demand.

d. There’s no concept of cursor types in a DataSet.

e. DataSets have no current record pointer You can use For Each loops to move through the data.

f. You can store many edits in a DataSet, and write them to the original data source in a single operation.

g. Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources.



51 What’s a bubbled event?

· When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents.



52 What data types do the RangeValidator control support?

· Integer, String, and Date.

53 Explain what a diffgram is, and a good use for one?

· The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. A good use is reading database data to an XML file to be sent to a Web Service.



54 What is the transport protocol you use to call a Web service?

· SOAP (Simple Object Access Protocol) is the preferred protocol.



55 What is ViewState?

· ViewState allows the state of objects (serializable) to be stored in a hidden field on the page. ViewState is transported to the client and back to the server, and is not stored on the server or any other external source. ViewState is used the retain the state of server-side objects between postabacks.



56 What does the "EnableViewState" property do? Why would I want it on or off?

· It allows the page to save the users input on a form across postbacks. It saves the server-side values for a given control into ViewState, which is stored as a hidden value on the page before sending the page to the clients browser. When the page is posted back to the server the server control is recreated with the state stored in viewstate.



57 What are the different types of Session state management options available with ASP.NET?

· ASP.NET provides In-Process and Out-of-Process state management. In-Process stores the session in memory on the web server. This requires the a "sticky-server" (or no load-balancing) so that the user is always reconnected to the same web server. Out-of-Process Session state management stores data in an external data source. The external data source may be either a SQL Server or a State Server service. Out-of-Process state management requires that all objects stored in session are serializable.



58 Differences Between XML and HTML?

Anyone with a fundamental grasp of XML should be able describe some of the main differences outlined in the table below

XML HTML

User definable tags Defined set of tags designed

forweb display

Content driven Format driven

End tags required for well formed End tags not required

documents

Quotes required around attributes Quotes not required

values

Slash required in empty tags Slash not required



59 Give a few examples of types of applications that can benefit from using XML.

There are literally thousands of applications that can benefit from XML technologies. The point of this question is not to have the candidate rattle off a laundry list of projects that they have worked on, but, rather, to allow the candidate to explain the rationale for choosing XML by citing a few real world examples. For instance, one appropriate answer is that XML allows content management systems to store documents independently of their format, which thereby reduces data redundancy. Another answer relates to B2B exchanges or supply chain management systems. In these instances, XML provides a mechanism for multiple companies to exchange data according to an agreed upon set of rules. A third common response involves wireless applications that require WML to render data on hand held devices.



60 What is DOM and how does it relate to XML?

o The Document Object Model (DOM) is an interface specification maintained by the W3C DOM Workgroup that defines an application independent mechanism to access, parse, or update XML data. In simple terms it is a hierarchical model that allows developers to manipulate XML documents easily Any developer that has worked extensively with XML should be able to discuss the concept and use of DOM objects freely. Additionally, it is not unreasonable to expect advanced candidates to thoroughly understand its internal workings and be able to explain how DOM differs from an event-based interface like SAX.

ASP.Net - 2

22 Should user input data validation occur server-side or client-side? Why?

· All user input data validation should occur on the server and minimally on the client-side, though it is a good way to reduce server load and network traffic because we can ensure that only data of the appropriate type is submitted from the form. It is totally insecure. The user can view the code used for validation and create a workaround for it. Secondly, the URL of the page that handles the data is freely visible in the original form page. This will allow unscrupulous users to send data from their own forms to your application. Client-side validation can sometimes be performed where deemed appropriate and feasible to provide a richer, more responsive experience for the user.

23 What is the difference between Server.Transfer and Response.Redirect?

a. Response.Redirect

: This tells the browser that the requested page can be found at a new location. The browser then initiates another request to the new page loading its contents in the browser. This results in two requests by the browser.

b. Server.Transfer

: It transfers execution from the first page to the second page on the server. As far as the browser client is concerned, it made one request and the initial page is the one responding with content. The benefit of this approach is one less round trip to the server from the client browser. Also, any posted form variables and query string parameters are available to the second page as well.

24 What is an interface and what is an abstract class?

· In an interface, all methods must be abstract (must not be defined). In an abstract class, some methods can be defined. In an interface, no accessibility modifiers are allowed, whereas it is allowed in abstract classes.

25 Session state vs. View state:

· In some cases, using view state is not feasible. The alternative for view state is session state. Session state is employed under the following situations:

a. Large amounts of data - View state tends to increase the size of both the HTML page sent to the browser and the size of form posted back. Hence session state is used.

b. Secure data - Though the view state data is encoded and may be encrypted, it is better and secure if no sensitive data is sent to the client. Thus, session state is a more secure option.

c. Problems in serializing of objects into view state - View state is efficient for a small set of data. Other types like DataSet are slower and can generate a very large view state.

26 Can two different programming languages be mixed in a single ASPX file?

· ASP.NET’s built-in parsers are used to remove code from ASPX files and create temporary files. Each parser understands only one language. Therefore mixing of languages in a single ASPX file is not possible.

- -

27 Is it possible to see the code that ASP.NET generates from an ASPX file?

· By enabling debugging using a <%@ Page Debug="true" %> directive in the ASPX file or a statement in Web.config, the generated code can be viewed. The code is stored in a CS or VB file (usually in the \%SystemRoot%\Microsoft.NET\Framework\v1.0.nnnn\Temporary ASP.NET Files).

28 Can a custom .NET data type be used in a Web form?

· This can be achieved by placing the DLL containing the custom data type in the application root’s bin directory and ASP.NET will automatically load the DLL when the type is referenced.

29 List the event handlers that can be included in Global.asax?

a. Application start and end event handlers

b. Session start and end event handlers

c. Per-request event handlers

d. Non-deterministic event handlers

30 Can the view state be protected from tampering?

· This can be achieved by including an @ Page directive with an EnableViewStateMac="true" attribute in each ASPX file that has to be protected. Another way is to include the statement in the Web.config file.

31 Can the view state be encrypted?

· The view state can be encrypted by setting EnableViewStateMac to true and either modifying the element in Machine.config to or by adding the above statement to Web.config.

32 When during the page processing cycle is ViewState available?

· The view state is available after the Init() and before the Render() methods are called during Page load.

33 Do Web controls support Cascading Style Sheets?

· All Web controls inherit a property named CssClass from the base class System.Web.UI.WebControls.WebControl which can be used to control the properties of the web control.

34 What namespaces are imported by default in ASPX files?

· The following namespaces are imported by default. Other namespaces must be imported manually using @ Import directives.

a. System

b. System.Collections

c. System.Collections.Specialized

d. System.Configuration

e. System.Text

f. System.Text.RegularExpressions

g. System.Web

h. System.Web.Caching

i. System.Web.Security

j. System.Web.SessionState

k. System.Web.UI

l. System.Web.UI.HtmlControls

m. System.Web.UI.WebControls

35 What classes are needed to send e-mail from an ASP.NET application?

· The classes MailMessage and SmtpMail have to be used to send email from an ASP.NET application. MailMessage and SmtpMail are classes defined in the .NET Framework Class Library’s System.Web.Mail namespace.

36 Why do some web service classes derive from System.Web.WebServices while others do not?

· Those Web Service classes which employ objects like Application, Session, Context, Server, and User have to derive from System.Web.WebServices. If it does not use these objects, it is not necessary to be derived from it.

37 What are VSDISCO files?

· VSDISCO files are DISCO files that enable dynamic discovery of Web Services. ASP.NET links the VSDISCO to a HTTP handler that scans the host directory and subdirectories for ASMX and DISCO files and returns a dynamically generated DISCO document. A client who requests a VSDISCO file gets back what appears to be a static DISCO document.

38 How can files be uploaded to Web pages in ASP.NET?

· This can be done by using the HtmlInputFile class to declare an instance of an tag. Then, a byte[] can be declared to read in the data from the input file. This can then be sent to the server.

39 How do I create an ASPX page that periodically refreshes itself?

· The following META tag can be used as a trigger to automatically refresh the page every n seconds:

40 How do I initialize a TextBox whose TextMode is "password", with a password?

· The TextBox’s Text property cannot be used to assign a value to a password field. Instead, its Value field can be used for that purpose.

ID="Password" RunAt="server" />