Featured Posts

<< >>

Microsoft DotNet Interview Questions 2012

Recently I gave lot of interviews for Dot Net developer positions in various leading companies. I came across numerous good interview questions which sometimes confuse us. I would like to share with you all. Whether System.String class is a value type or reference type? Can we create an object of System.String class using new keyword? [...]

DZoneDeliciousLinkedInRedditTechnorati FavoritesStumbleUponShare

What is MVC (Model-View-controller) architecture in Java

The use of the MVC architecture is to separate the business logic and application data from the presentation data to the user.Here are the reasons why we should use the MVC design pattern. 1.They are reusable: When the problems recurs, there is no need to invent a new solution, we just have to follow the [...]

DZoneDeliciousLinkedInRedditTechnorati FavoritesStumbleUponShare

DateTime type in C#

Recap In an earlier post Microsoft Dotnet Interview Questions 2012, question no. 7 was about DateTime type. In this post I would answer that. DateTime – Value Type or Reference Type DateTime type is a structure in C#. Hence DateTime is a Value type. Constructors for the DateTime type MSDN provides a whole list of [...]

DZoneDeliciousLinkedInRedditTechnorati FavoritesStumbleUponShare

Microsoft DotNet Interview Questions 2012

Recently I gave lot of interviews for Dot Net developer positions in various leading companies. I came across numerous good interview questions which sometimes confuse us. I would like to share with you all.

  1. Whether System.String class is a value type or reference type? Can we create an object of System.String class using new keyword?

  2. What is the difference between System.String class and string keyword. Similarly what is the difference between int and System.Int32 etc.

  3. Why System.String class is immutable?Whats is the purpose behind this design by CLR?

  4. Are there any other types apart from System.String that are immutable? If yes which ones. If no then why this special treatment for System.String?
  5. How is StringBuilder class implemented internally? What is the best approach to create a custom StringBuilder class?

  6. Why cant methods be overloaded based on return type in C#. Is it allowed by CLR? Is this feature available in any other .NET language?

  7. DateTime is reference type or value type?
  8. Answer:DateTime type in C#

  9. What are the advantages or disadvantges of using a value type over reference type?

  10. What are the advantages or disadvantges of using a reference type over value type?

  11. What is the main benefit of using Generic types?
  12. Answer:Why use generics in C# dot net

  13. Explain how boxing process is done by CLR from memory standpoint.

  14. Explain how unboxing process is done by CLR from memory standpoint.

  15. How CLR assigns allocates memory to references types? What are the operations that happen in memory when a reference of a type is created. What operations get executed when a new instance is created using new keyword and assigned to the reference of a class?

  16. How/Where is memory allocated for Static variables?

  17. How does CLR calls virtual methods? How does it actually trace the address in memory of the overridden definition of a virtual method?

  18. If protected accessor means accessible in family and internal means assembly(accessible in same assembly) then protected internal means? “family or assembly” or “family and assembly?

  19. Why cant someone create an object of static class in dotnet?
  20. Answer: This is because CLR does not emit a default constructor in IL for the static class. For more about static keyword please browse to What is Static keyword in C#.


  21. What is a Managed Module?

  22. What is Strongly Named assembly?How do we attach strong name to an assesmbly why should that be done?

  23. Is a strongly Named Assembly tamper proof? Consider someone opens the assembly in a notepad and changes the binary content of the assembly and saves the file. Will this corrupted assembly get loaded? If Not why?

  24. Can a assembly be unloaded? How can this be achieved?

  25. What is the main reason of introducing the concept of AppDomains?

  26. If there are 2 websites running under IIS and one of them crashes, will it imapct the other one?

  27. Suppose you have developed an assmbly and distributed to hundreds of clients. After one year you relese a new version of the assembly, then how would this new version be deployed in production at all applications?

  28. How Garbage Collector works internally? Briefly describe the generations approach used by GC.

  29. Can GC be called on demand? Will GC get called when GC.Collect() method is executed?



Please hold your breath I will add the answers to these questions in coming days. Till then feedback and answers are welcome in comments but do provide the question number.

Shout it

DZoneDeliciousLinkedInRedditTechnorati FavoritesStumbleUponShare

What is MVC (Model-View-controller) architecture in Java

The use of the MVC architecture is to separate the business logic and application data from the presentation data to the user.Here are the reasons why we should use the MVC design pattern.

1.They are reusable: When the problems recurs, there is no need to invent a new solution, we just have to follow the pattern and adapt it as necessary.

2.They are expressive: By using the MVC design pattern our application becomes more expressive.

1).Model:
The model object knows about all the data that need to be displayed. It is model who is aware about all the operations that can be applied to transform that object. It only represents the data of an application. The model represents enterprise data and the business rules that govern access to and updates of this data. Model is not aware about the presentation data and how that data will be displayed to the browser.

2).View :
The view represents the presentation of the application. The view object refers to the model. It uses the query methods of the model to obtain the contents and renders it. The view is not dependent on the application logic. It remains same if there is any modification in the business logic. In other words, we can say that it is the responsibility of the of the view’s to maintain the consistency in its presentation when the model changes.

3).Controller:
Whenever the user sends a request for something then it always go through the controller. The controller is responsible for intercepting the requests from view and passes it to the model for the appropriate action. After the action has been taken on the data, the controller is responsible for directing the appropriate view to the user. In GUIs, the views and the controllers often work very closely together.
Difference between Model 1 and Model 2 architecture:

Features of MVC1:
1.Html or jsp files are used to code the presentation. To retrieve the data JavaBean can be used.

2.In mvc1 architecture all the view, control elements are implemented using Servlets or Jsp.

3.In MVC1 there is tight coupling between page and model as data access is usually done using Custom tag or through java bean call.

Features of MVC2:

1.The MVC2 architecture removes the page centric property of MVC1architecture by separating Presentation, control logic and the application state.

2.In MVC2 architecture there is only one controller which receives all the request for the application and is responsible for taking appropriate action in response to each request.

DZoneDeliciousLinkedInRedditTechnorati FavoritesStumbleUponShare

DateTime type in C#

Recap

In an earlier post Microsoft Dotnet Interview Questions 2012, question no. 7 was about DateTime type. In this post I would answer that.

DateTime – Value Type or Reference Type

DateTime type is a structure in C#. Hence DateTime is a Value type.

Constructors for the DateTime type
MSDN provides a whole list of constructors which are available on this type. Constructors with combinations of day,month, year,time etc are available using which a new datetime object can be easily constructed.

DZoneDeliciousLinkedInRedditTechnorati FavoritesStumbleUponShare

Convert Javascript value to Java object

Today,i need to convert Javascript value to Java object.How to do that.little tedious…..

I found workaround for this.We are providing you two ways:

1)abc.jsp:
In this , we are making javascript variable as request parameter and getting value using request.getParameter method. :-)


<html>
<script language="javascript" type="text/javascript">
function call(){
var name = "techsamosa";
window.location.replace("abc.jsp?name="+name);
}
</script>
<input type="button" value="Get" onclick='call()'>
<%
String name=request.getParameter("name");
if(name!=null){
out.println(name);
}
%>
</html>

Another way

2)xyz.jsp:- In this inside the scriplet we are writing the script tag and passing the javascript value to string object in java

<script>
var v="Techsamosa";
</script>
<% String st="<script>document.writeln(v)</script>";
out.println("value="+st); %>

Happy coding ……………….

DZoneDeliciousLinkedInRedditTechnorati FavoritesStumbleUponShare

Why use Generics in C# dot net

Recap

In an earlier post Microsoft Dotnet Interview Questions 2012, question no. 10 was about benefits of generics. In this post I would answer that.

Main benefits of Generics
Generics typically provides a lot of performance and code safety benefits which are listed below:

  1. Generics enforce Type Safety: Type safety means that only object compatible with specified types will be used in the generic algorithm. This helps to write a code which is less prone to errors. When generics are used, compiler knows that only a specific type will be encountered. For example, a foreach loop can be easily used on a List because it contains only strings. If we had used a for loop as well, it would work fine. But consider if List was not generic and it might contain integers as well, then it would have made the code prone to errors.
  2. Performance boost: Usage of generics boost the performance of the system, since it avoids a lot of Boxing and Unboxing process. This feature is a positive side effect of type safety as well. Traditionally, if some algorithm had to be written which should work on multiple data types, it would be based on Object type. It meant if user ran the algorithm for value type, then a lot of boxing and unboxing operations would happen in the algorithm. Since generics are type safe, and are not based on Object type, these operations are avoided and performance is boosted.
  3. Clean code: Again a positive side effect of Type safety, since the code works on a single data type, there is no code for casting and reverse casting of variables. That ends up with cleaner source code.

So we have seen that the major benefit of using generics is that they provide type safety which in turns boosts the performance.

Any questions comments are welcome.

DZoneDeliciousLinkedInRedditTechnorati FavoritesStumbleUponShare

Book Review : Ext JS 4 First Look

The folks at Packt asked me to review one of their book on EXTJS 4 If you are interested in buying it (a judgment you may reserve until after you have read the review)

“http://www.packtpub.com/ext-js-4-first-look/book” this is link you can go

Loiane Groner iS a EXT-JS consultant, she is expert in EXT JS. As far as I can recall, I have never met them but I follow her blog http://loianegroner.com regularly

The Packt model is an interesting one. They are an online publishing house who approach subject matter experts and offer them an advance and a good commission for writing a book for them. They have approached me a couple of times but I have turned them down on both occasions simply due to a lack of time. Given the movement towards e-readers and related devices I believe it is a business model most publishers will eventually adopt.

Overview and Structure of the Book

The first thing you will probably notice is the size of the document. This is no brief summary of the new features. This is over 340 pages covering what has changed since EXT JS 3 in EXT JS 4 with a full index in the back. The structure of the book is:

• The usual preliminary bits (About the Authors, Acknowledgement, Table of Contents etc.)
• Chapter 1: What new in EXT JS 4.
• Chapter 2: The new Data package
• Chapter 3: Upgraded Layout
• Chapter 4: Upgraded Charts
• Chapter 5: Upgraded Grid, Tree and Form
• Chapter 6: Ext JS 4 Themes
• Chapter 7: MVC Application Architecture
• Appendix
• Index

I like this structure as it parallels the steps one would take in setting up a EXT JS4. The titles are also plain English e.g. ‘Ext JS 4 First Look’ making it easier to know where to go. To add a bit of a flow to the book, they also put it in the examples,real life scenarios
What is missing is – This book is not for the beginners who are learning EXT JS from scratch. Major feature release.
Ext JS 4 introduces major changes compared to Ext JS 3..You will find lot of changes There is a new data package, new charts, and new, updated layouts. The framework was completely changed from EXT JS 3 for increasing the performance.
This book covering all changes in EXT JS 4 , all new features using coding example with detailed explanation and screenshot of code as well the result too. Book will make you understand the changes in EXT JS 4 with presented examples and using this book you can easily migrate the application from EXT JS 3 to EXT JS 4 application

Chapter 1: What’s New in Ext JS 4

This chapter provides an introduction to all major changes between Ext JS 3 and Ext JS 4. Ext JS 4 presents a vast improvement in all packages; the framework was completely rewritten to boost performance and make learning and configuring easy. This chapter covers all these changes, from class system, to an overview, to the new Sencha platform
Good high-level review to introduce the reader to these completely new features

Chapter 2: The New Data Package

This chapters covers all the changes in the data packageI am amazed to see the Sencha Touch framework for mobile application This chapter introduces the new Model class, associations, proxies, operations, batches, and the new features of the Store class.
What this means is the book lends itself to system architects with a good understanding of the configuration options of the system but not so much to people who are new to either system.

Chapter 3: Upgraded Layouts

This is a great chapter on the awesome work Sencha Team has done on improving the layout. It covers all changes made to the existing layouts, and the new component layout engines, such as dock, toolbar, field, and trigger field layouts. It also covers the changes made to the container layouts, such as fit, border, table, anchor, card, accordion, and so on..
If you are stuck in designing the layout of application then reading this chapter is worth of. ?

Chapter 4: Upgraded Charts

I like this chapter after reading this a lot. Chapters presents the new JavaScript-powered Ext JS 4 charts. And what you can expect more the no flash is required anymore. This chapter introduces the new draw package, which is the base package for the new chart package. It also covers how to configure chart axis, legend, customized themes, and Ext JS 4 chart series, such as Bar, Column, Line, Area, Scatter, Pie, Radar, and Gauge.

Chapter 5: Upgraded Grid, Tree, and Form

Again, this is a big topic for one chapter. It mention and demonstrates the upgraded Ext JS Components. Very well explained the more performance and more developer flexibility. Some new features and plugins for Components covered in this chapter are: grid, tree, and forms.

Chapter 6: Ext JS 4 Themes

This is probably one of the best example or step by step way of creating on how developer can customize and create a new theme by using CSS architecture, which uses Sass and Compass.

Chapter 7: MVC Application Architecture

. One nice touch in this chapter how MVC architecture applied or implemented to Ext JS 4 applications. This chapter as with others is designed to give the reader a feel for creating a MVC EXT JS 4 application. Steps by steps instruction given in this chapter. Chapter also includes the structure of EXT JS 4 application project structure and how reader can manage the component, files in EXT project structure.
Appendix A, Ext JS 4 Versus Ext JS 3 Class Names,
It presents a comparison list between Ext JS 3 classes and Ext JS 4 class names. In this new version of Ext JS, the names of some classes have changed, and this list can help you find the new Ext JS 4 class names easily, while migrating an application from Ext JS 3 to Ext JS 4 Beta.

Conclusions

This book is not a comprehensive guide to the learn EXT JS 4 or EXT JS. Rather, it is an introduction to some of the new features of the product, compared to EXT JS 3. .It is good guide if you want migrate application from EXT JS 3 to EXT JS 4 or if you want learn ,understand the new feature and advanced topic on EXT JS 4.The way author mentioned he pseudo code with example and detailed description is really good. Features of the product they do cover are covered very well. What I mean by this is their high-level summaries of large topics, such as Layout ,tree and form, cover the essential elements and their treatment of smaller topics, such as EXT JS 4 Theme, MVC Application Architecture topic are some of the best I have seen.

While there is not as much bang for buck as, say, Loiane Groner’s book, the EXT JS 4 developer will not have to filter out a rehash of the version 4 features as this book assumes that knowledge. Where I see this book working is as good migration guide. While those volumes allow the reader to drill down into a specific topic, this book, uniquely, gives a much greater context to the features in question, providing a practical example as an integral part of the narrative

DZoneDeliciousLinkedInRedditTechnorati FavoritesStumbleUponShare