Tuesday, October 27, 2020

C# Interview Questions (Events and Delegates)


 


Events and Delegates


1. What’s a delegate? 
A delegate object encapsulates a reference to a method. 

2. What’s a multicast delegate? 
A delegate that has multiple handlers assigned to it. Each assigned handler (method) is called.

3. What’s the implicit name of the parameter that gets passed into the class’ set method?
Value and it’s datatype depends on whatever variable we’re changing.

4. How do you inherit from a class in C#? 
Place a colon and then the name of the base class.

5. Does C# supports multiple inheritances?
No, use interfaces instead.

6. When you inherit a protected class-level variable, who is it available to?
Classes in the same namespace.

7. Are private class-level variables inherited?
Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. 

8. Describe the accessibility modifier protected internal.?
It’s available to derived classes and classes within the same Assembly (and naturally, from the base class it’s declared in).

9. C# provides a default constructor for me. I write a constructor that takes a string as a parameter but want to keep the no parameter one. How many constructors should I write? 
Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write one yourself, even if there’s no implementation in it.

10. What’s the top .NET class that everything is derived from? 
System.Object.

11. How’s the method overriding different from overloading? 
When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class.

12. What does the keyword virtual mean in the method definition?
The method can be over-ridden.

13. Can you declare the override method static while the original method is non-static?
No, you can’t, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override.

Monday, October 26, 2020

C# Interview Questions (Method and Property )

 



 

Method and Property Questions 


1. What’s the implicit name of the parameter that gets passed into the set method/property of a class? 
Value. The data type of the value parameter is defined by whatever data type the property is declared.

2. What does the keyword “virtual” declare for a method or property? 
The method or property can be overridden. 

3. How is method overriding different from method overloading? 
When overriding a method, you change the behavior of the method for the derived class. Overloading a method simply involves having another method with the same name within the class. 

4. Can you declare an override method to be static if the original method is not static? 
No. The signature of the virtual method must remain the same. (Note: Only the keyword virtual is changed to keyword override) 

5. What are the different ways a method can be overloaded? 
Different parameter data types, different the number of parameters, different order of parameters. 

6. If the base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?
Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.

C# interview questions (Class)


 

Class Questions



1.What is the syntax to inherit from a class in C#? 
Place a colon and then the name of the base class.
Example: class MyNewClass : MyBaseClass 

2.Can you prevent your class from being inherited by another class? 
Yes. The keyword “sealed” will prevent the class from being inherited. 

3.Can you allow a class to be inherited, but prevent the method from being over-ridden?
Yes. Just leave the class public and make the method sealed. 

4.What’s an abstract class?
A class that cannot be instantiated. An abstract class is a class that must be inherited and has the methods overridden. An abstract class is essentially a blueprint for a class without any implementation. 

5.When do you absolutely have to declare a class as abstract?
1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden. 
2. When at least one of the methods in the class is abstract. 

6.What is it an interface class?
Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide the implementation. They are implemented by classes and defined as separate entities from classes. 

7.Why can’t you specify the accessibility modifier for methods inside the interface?
They all must be public and are therefore public by default. 
 
8.Can you inherit multiple interfaces?
Yes. .NET does support multiple interfaces. 

9.What happens if you inherit multiple interfaces and they have conflicting method names?
It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay. 

10. What’s the difference between an interface and abstract class?
In an interface class, all methods are abstract - there is no implementation. In an abstract class some methods can be concrete. In an interface class, no accessibility modifiers are allowed. An abstract class may have accessibility modifiers. 

11. What is the difference between a Struct and a Class?
Structs are value-type variables and are thus saved on the stack, additional overhead but faster retrieval. Another difference is that structs cannot inherit. 


Mostly Asked C# Interview Questions


 1.Does C# support multiple-inheritance? 
    No. But you can use Interfaces.


2.Where is a protected class-level variable available? 
    It is available to any sub-class derived from a base class


3.Are private class-level variables inherited? 
    Yes, but they are not accessible. 


4.Describe the accessibility modifier “protected internal”. 
    It is available to classes that are within the same assembly and derived from the specified base class. 


6.Which class is at the top of .NET class hierarchy? 
    System.Object. 


7.What does the term immutable mean?
    The data value may not be changed. 


8.What’s the difference between System.String and System.Text.StringBuilder classes?
    System.String is immutable.
    System.StringBuilder was designed to have a mutable string where a variety of operations     can be performed. 


9.What’s the advantage of using System.Text.StringBuilder over System.String?
    StringBuilder is more efficient in cases where there is a large amount of string                  manipulation. 
    Strings are immutable, so each time a string is changed, a new instance in memory is created.


10.Can you store multiple data types in the System? Array?
    No


11.What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
    The Clone() method returns a new array (a shallow copy) object containing all the                 elements in the original array. 
    The CopyTo() method copies the elements into another existing array.
    Both perform a shallow copy. A shallow copy means the contents (each array element)         contains references to the same object as the elements in the original array. A deep copy     (which neither of these methods performs)     would create a new instance of each element's object, resulting in a different, yet identical object.


12.How can you sort the elements of the array in descending order?
      By calling Sort() and then Reverse() methods. 


13.What’s the .NET collection class, that allows an element to be accessed using a unique key?
    
HashTable.


14.What class is underneath the SortedList class?
    A sorted HashTable. 


15.Will the finally block get executed if an exception has not occurred?
    Yes. 


16.What’s the C# syntax to catch any possible exception?
    
A catch block that catches the exception of type System. Exception.


17.Can multiple catches blocks are executed for a single try statement?
    
No. Once the proper catch block processed, control is transferred to the finally block.


18.Explain the three services model commonly know as a three-tier application?
    Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources). 



Sunday, October 25, 2020

Software development life cycle (SDLC)

  

What is software product development?

 

It structures the work of the development teams enabling them to meet the project requirements, meet deadlines, and stay within the budget.

Software development is the process of conceiving, specifying, designing, programming, documenting, testing, and bug fixing involved in creating and maintaining applications, frameworks, or other software components.

Each of the stages of the software development life cycle depends on the model of the software development process a company chooses whether it’s agile, waterfall, V-model, RAD (rapid app development) or incremental.

 

The Different Software Product Development Methodologies

There are several software development methodologies in the market today, each offering a different set of benefits: from improved process efficiency to minimized risk, enhanced scalability to continuous iterations. Here’s a look at the three most popular software product development methodologies – waterfall, agile, and scrum – and see which one serves your business needs best.


Waterfall


One of the earliest software development methodologies, the waterfall model incorporates a series of sequential steps: conception, initiation, analysis, design, construction, testing, production/implementation, and maintenance. Since the model ensures distinct goals are accomplished, it is ideal for projects where requirements are clear and also for projects where detailed, precise, and accurate documents describe how the system is to be produced.


Agile


The agile method works on an iterative approach, where new releases of the system are created and made available to customers every few weeks. For each stage of the product, more features can be tested, added, and again tested after getting feedback from customers. Since each team works in parallel, checking for product quality all along, agile methodology saves time and ensures the end product meets the intended requirements.



Scrum


Scrum, a subset of Agile, is used to manage the software product development process at the macro level. It deploys an incremental approach and follows the values and principles of agile; also, it covers further definitions and specifications by considering some critical software development practices. Most scrum principles are borrowed from the Agile methodology: especially related to customer feedback and fast increments. This approach is best suitable for products with changing requirements.

Scrum is an agile development methodology used in the development of Software based on an iterative and incremental process. Scrum is an adaptable, fast, flexible, and effective agile framework that is designed to deliver value to the customer throughout the development of the project.


Stages of Software Development 






Stage 1: Idea Generation

It all starts with a great idea. But any idea needs to be carefully thought over to be implemented.
The ideation phase involves an analysis of the problem statement as defined by the customer. By extracting key requirements, developers ideate a proper solution that can fulfill the customer’s needs. Conceptualization involves formulating the idea or concept; once the scope of the project is defined, a list of desired design features and requirements is created.
Your goal should be to generate many worthy ideas that can form the foundation for the New Product Development strategy. The major part of this stage should be to give significance to brainstorming sessions where solving customer problems is given precedence.




 

Stage 2: Requirements and feasibility analysis

During this phase of software development, the project is defined in details and the analysis of the project’s feasibility is carried out. To build an actionable solution, clean code and catchy design is not enough, you first need for the development team to get a deeper understanding of the project goal and collect all the requirements. Feasibility analysis displays all the technical and economical aspects impacting the application development process: time, resources and tasks and involvement estimates from the team members help calculate ROI and determine project cost and profit. Requirements analysis also helps identify the risks at the very start so that risk mitigation strategies can be worked out from the very beginning. Clear structured documentation ensures better cooperation and understanding of both the development team and clients.


Stage 3: Design 



Software design is a preeminent component of software project development. During the design phase, the actual conceptualizing of the solution is created, that is the detailed software architecture meeting specific project requirements is created. Custom-tailored software design by software architects and engineers sets definite workflows and standards and encompasses clear overall solution/product design together with database structure and design. During this phase, the whole structure of the project is built with the final prototype and mockups used for the next stages of the software development process.

The requirements are broken down further to forecast the timeline and estimate efforts; once requirements are clearly detailed, technical resources are identified, specific tasks are assigned to each individual and they are provided with the necessary documentation required to begin the design and development process. Specific designs and workflows for the application as well as the tools and technology on which the solutions will be built are identified.

Based on the development approach, tasks are broken down and the product can be completed within the defined timeline. Several key documents including the design document, the functional requirement specification document, and coding standards that will be followed during the final delivery is created.



Stage 4: Development & coding

The development phase is about writing code and converting design documentation into the actual software within the software development process. This stage of SDLC is generally the longest as it’s the backbone of the whole process and there are a number of vital things to pay attention to. The software engineering team has to make sure their code meets the software requirements specifications, conforms to the stakeholders’ requirements, etc. 

Stage 5: Integration and testing

 

Since quality is key to the success of any software product, the quality assurance stage involves build installation, system testing, bug fixing, user acceptance testing (UAT), and test report generation. After a release has been completed, the development and testing phases are performed iteratively as issues are found, corrected, and verified. At the end of this phase, a stable product with minimal issues is ready for deployment. It is always best to allow time for UAT testing before approving an application for production implementation.

Now that the software is built and completed the next phase involving system testing and integration starts. Depending on the adopted testing processes it might vary. But typically the QA engineers use a whole range of frameworks alongside continuous integration executing unit tests, automation compilation, and testing. The Quality Assurance team conducts a series of tests including functionality testing, systems integration, and interoperability as well as user acceptance testing, etc. in order to ensure the code is clean and business goals of the solution are met. Verification and validation make up a vital part in ensuring the application/solution is completed successfully. Now that the software is bug-free, the implementation phase starts.



Stage 6: Implementation and deployment



It’s done step-by-step according to the implementation plan. The newly built and tested application is moved to production including data and components transfer while during the next releases only the specific changes will be deployed. Depending on the complexity of the project it might be a straightforward release (if the project is simple) or staggered released (in stages) in case of a more complex project. Now system analysts and the end-users can actually see and try out the ready application.

The transfer of product knowledge from the individual, team, department, or organization onto the customer characterizes this phase. During this phase of knowledge transfer, change requests, impact analysis, and all pending documentation is completed. At the end of this phase, the development team hands over all the aspects of the project to the customer including code, documents, and software licenses.

 




Stage 7: Operations and maintenance

The final stage of the software development lifecycle includes maintenance and regular updates. The phase is treated with the utmost attention since during the stage the product is polished, upgraded, enhanced, and fine-tuned according to the real-world feedback on its performance. That’s exactly a perfect timing to robust the application’s functionalities to upgrade its performance and modify according to the actual needs of the end-user add new capabilities or meet additional user requirements.

Sustainability ensures that the software will continue to be available in the future, on new platforms, and meeting new needs. Sustainability ensures the software product is easy to evolve, satisfies its intent over time, survives uncertainty, and supports relevant concerns. The way sustainability is approached will depend on many factors, such as how important the software is, its maturity level, the size of its community, and the resources available for achieving sustainability.


Path to Success


With companies investing considerable time and effort in developing software, yet being at risk of failure, the significance of the software product development process is irrefutable. The major outcome of following a prescribed software development process is that it will give code development and project execution fluency to all of the project stakeholders. It enables system requirements to be tracked to the business needs and provides a solution that best fits needs. By considering the pros and cons of the methodology, choose the model that works best for your organization, and embark on the path to success.




Sunday, October 18, 2020

Top 30 ASP.NET interview questions and answers

 



Important of  Net Framework

1. What is the main difference between an ASP.NET Web application and a traditional Windows application?

ASP.NET Web applications run under common language runtime using managed code where as Unmanaged Windows application runs under Windows using unmanaged code.


2. What are the two main parts of the .NET Framework?

The two main parts of the .NET Framework are

   1. The common language runtime (CLR).

   2. The .NET Framework class library.


3. When can’t you use ASP.NET to create a Web application?

When you are developing for non–Microsoft Windows Web servers, such as Linux/Apache.


4. List the four major differences between Web and Windows applications.

Web forms cannot use the standard Windows controls. Instead, they use server controls, HTML controls, user controls, or custom controls created especially for Web forms.

Web applications are displayed in a browser. Windows applications display their own windows and have more control over how those windows are displayed.

Web forms are instantiated on the server, sent to the browser, and destroyed immediately. Windows forms are instantiated, exist for as long as needed, and are destroyed.

Web applications run on a server and are displayed remotely on clients. Windows applications run on the same machine they are displayed on.


5. Describe the life cycle of a Web application: When are Web forms instantiated and how long do they exist?

A Web application starts with the first request for a resource within the application’s boundaries. Web forms are instantiated when they are requested. They are processed by the server and are abandoned immediately after the server sends its response to the client. A Web application ends after all client sessions end.


6. How do you preserve persistent data, such as simple variables, in a Web application?

You can preserve data in state variables, such as ApplicationState, SessionState, or ViewState.


7. How does the .NET Framework organize its classes?

The .NET Framework uses namespaces to organize its classes.


8. In Visual Basic .NET, what is the difference between a class module and a code module?

Class modules are instantiated at run time to create objects that provide separate storage for variables and properties in each instance. Code modules do not have instances, so any module-level variables they use are shared among calls to the module’s procedures.


9. In Visual C#, how do you declare a method to make it available without having to first instantiate an object from the class?

To create a method that can be called without instantiating an object, declare that method as static.


10. How do you call a member of a base class from within a derived class?

To refer to a member of a base class in Visual Basic .NET, use the MyBase keyword. To refer to a member of a base class in Visual C#, use the base keyword.



11. Where would you save the following data items so that they persist between requests to a Web form?

A control created at run time, an object that provides services to all users, User preferences

Save controls created at run time in the Page object’s ViewState.

Save objects that provide services to all users in the Application state.

Save user preferences in SessionState.


12. What is the main difference between the Button server control and the Button HTML control?

When clicked, the Button server control triggers an ASP.NET Click event procedure on the server. The Button HTML control triggers the event procedure indicated in the button’s onclick attribute, which runs on the client.

 

13. How do you get several RadioButton controls to interoperate on a Web form so that only one of the RadioButton controls can have a value of True/true at any given time?

Set the Group Name property of each RadioButton to the same name.

 

14. Why does ASP.NET perform validation on both the client and the server?

Client-side validation helps avoid round-trips to the server. Validating on the client ensures that the data is valid before it is submitted, in most cases. However, because validation might be turned off (or maliciously hacked) on the client, data must be revalidated on the server side. This provides full assurance that the data is valid while avoiding as many round-trips as possible.

 

15. What types of validation would you use to verify that a user entered a valid ­customer number?

You would use a RequiredFieldValidator and a RegularExpressionValidator. If you have access to a list of expected customer numbers, you could replace the RegularExpressionValidator with a CustomValidator that checked the list.


16. What is wrong with the following line of code?

Server.Transfer ("Default.htm");

You can’t use the Transfer method with HTML pages. It works only with .aspx pages.

 

17. Why can’t you open a new browser window from within server code?

Server code executes on the server, whereas the new window is created on the client. You need to use client-side code to do things that affect the client, such as upload files, display new windows, or navigate back in history.

 

18. What steps would you follow and what objects would you use to quickly find the number of records in a database table?

There are two ways to accomplish this task:

Use a database connection and a command object to execute a SQL command that re-turns the number of rows in the table.

Use a database connection and data adapter object to create a data set for the table, and then get the number rows in the data set.

 

19. How do typed data sets differ from untyped data sets, and what are the advantages of typed data sets?

Typed data sets use explicit names and data types for their members, whereas untyped data sets use collections to refer to their members. The following examples show a typed reference vs. an untyped reference to a data item:

// Typed reference to the Contacts table's HomePhone column.

DataSet1.Contacts.HomePhoneColumn.Caption = "@Home";

// untyped reference to the Contacts table's HomePhone column.

DataSet1.Tables ["Contacts"].Columns ["HomePhone"].Caption = "@Home";

Typed data sets do error checking at design time. This error checking helps catch typos and type mismatch errors, which would be detected only at run time with untyped data sets.

 

20. How do you call a stored procedure?

Create a command object, set the object’s CommandText property to the name of the stored procedure, and set the CommandType property to StoredProcedure. To execute the stored procedure, use the command object’s ExecuteNonQuery, ExcecuteScalar, ExecuteReader, or ExecutelXmlReader method. For example, the following code calls the Ten Most Expensive Products stored procedure on the Northwind Traders database:

// create a connection for NorthWind Trader's database.

SqlConnection connNWind = new SqlConnection ("integrated security=SSPI;" +

"data source=(local);initial catalog=Northwind");

// Create a command object to execute.

SqlCommand cmdTopTen = new SqlCommand(connNWind);

cmdTopTen.CommandText = "Ten Most Expensive Products";

// Set the command properties.

cmdTopTen.CommandType = CommandType.StoredProcedure;

// create a data reader object to get the results.

SqlDataReader drdTopTen;

// Open the connection.

connNWind.Open();

// Excecute the stored procedure.

drdTopTen = cmdTopTen.ExecuteReader();

 

 

21. Explain the difference between handling transactions at the data set level and at the database level.

Data sets provide implicit transactions, because changes to the data set aren’t made permanent in the database until you call the Update method. To handle transactions in a data set, process the Update method and check for errors. If errors occur during an update, none of the changes from the data set is made in the database. You can try to correct the error and resubmit the update, or you can roll back the changes to the data set using the RejectChanges method.

Databases provide explicit transactions through the Transaction object. You create a Transaction object from a database connection and then assign that Transaction object to the commands you want to include in the transaction through the command object’s Transaction property. As you perform the commands on the database, you check for errors. If errors occur, you can either try to correct them and resubmit the command, or you can restore the state of the database using the Transaction object’s RollBack method. If no errors occur, you can make the changes permanent by calling the transaction object’s Commit method.

 

22. Explain why exception handling is important to a completed application.

When an unhandled exception occurs in an application, the application stops—the user can’t proceed, and any work he or she did immediately prior to the exception is lost. Exception handling provides a way to intercept and correct unusual occurrences that would otherwise cause these problems.

 

23. List two different exception-handling approaches in ASP.NET Web applications.

Exceptions can be handled in exception-handling blocks using the Try, Catch, and finally keywords in Visual Basic .NET or the try, catch, and finally keywords in Visual C#. They can also be handled using Error event procedures at the Global, Application, or Page levels using the Server object’s GetLastError and ClearError methods.

 

24. Describe the purpose of error pages and why they are needed.

Because Web applications run over the Internet, some exceptions occur outside the scope of the application. This means that your application can’t respond directly to these exceptions. These types of exceptions are identified by HTTP response codes, which IIS can respond to by displaying custom error pages listed in your application’s Web.config file.

 

25. Explain why tracing helps with exception handling.

Tracing allows you to record unusual events while your application is running, without users being aware of it. If an unanticipated exception occurs, your application can write a message to the trace log, which helps you diagnose problems during testing and after deployment.

 

26. Write the HTML for a hyperlink that will send mail when the user clicks the link.

&late href="mailto:you@pragim.com?SUBJECT=Sending from a client&BODY=some message text."> Send mail

 

 

27. Write the code that creates a cookie containing the user name Rob Young and the current date to the user’s computer. Set the cookie to remain on the user’s computer for 30 days.

HttpCookie cookUserInfo = new HttpCookie("UserInfo");

CookUserInfo["Name"] = "Rob Young";

CookUserInfo["Time"] = DateTime.Now.ToString();

cookUserInfo.Expires = DateTime.Now.AddDays(30);

Response.Cookies.Add(cookUserInfo);


28. What attribute do you use to hide a public .NET class from COM?

Use the ComVisible attribute to select which public .NET classes and members are visible to COM. This attribute applies hierarchically for the assembly, class, and member levels.

 

29. Why can’t you open a new browser window using server-side code? How would you display a page in a new window with a client-side script?

Server-side code can execute tasks only on the server. To perform a task on the client’s computer, such as opening a new browser window, the code needs to run on the client.

You can open a new window using the DOM window object. For example, the following HTML Button control opens a Help page in a new window:

< button id="butHelp" onclick="window.open('help.aspx', 'help', 'height=200,width=300')" > Help 


30. Which ASP.NET authentication mode is best suited to identifying and authorizing users who belong to a corporate network?

Windows authentication is best suited to authenticating users of a corporate network because it uses the accounts and permissions that already exist for network users.



NET Core Code Security, Authorization/Authentication, and code architecture

Complex NET Core interview questions (Code Security, Authorization/Authentication, and code architecture)  _________________________________...