250
Topic Covered for Technical Interview Questions 1. Software Testing Interview Questions a. Software Testing Basics b. Testing Techniques c. The Software Process d. CMMI (Capability Maturity Model Integration) e. Six Sigma f. Metrics g. Automated Testing h. Testing Estimation 2. Data Structures 3. The C Language Basics 4. Microsoft SQL Server a. SQL Server General Questions b. SQL Server Common Questions c. SQL Server 2008 5. Database Management a. DBMS Basics b. Database Management System 6. Java Programmin a. Core Java b. Java Basics 7. Selenium Questions a. Generic Selenium Questions b. Selenium IDE Questions c. Selenium RC (Selenium 1.0) Questions d. Selenium Grid Questions e. Web Driver (Selenium 2.0) Questions f. Selenium Tool Implementation Misc Questions g. Selenium Interview Questions, Java Selenium Interview Questions QA Keval Shah Site: shahkeval.wordpress.com +919624928454 Email ID: [email protected]

General technical interview questions

Embed Size (px)

Citation preview

Page 1: General technical interview questions

Topic Covered for Technical Interview Questions

1. Software Testing Interview Questionsa. Software Testing Basicsb. Testing Techniquesc. The Software Process  d. CMMI (Capability Maturity Model Integration)e. Six Sigmaf. Metricsg. Automated Testingh. Testing Estimation 

2. Data Structures3. The C Language Basics 4. Microsoft SQL Server

a. SQL Server General Questionsb. SQL Server Common Questionsc. SQL Server 2008

5. Database Managementa. DBMS Basicsb. Database Management System

6. Java Programmina. Core Javab. Java Basics

7. Selenium Questionsa. Generic Selenium Questionsb. Selenium IDE Questionsc. Selenium RC (Selenium 1.0) Questionsd. Selenium Grid Questionse. Web Driver (Selenium 2.0) Questionsf. Selenium Tool Implementation Misc Questionsg. Selenium Interview Questions, Java Selenium Interview Questions

Software Testing Basics

QA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 2: General technical interview questions

1. Can you explain the PDCA cycle and where testing fits in?

Software testing is an important part of the software development process. In normal software development there are four important steps, also referred to, in short, as the PDCA (Plan, Do, Check, Act) cycle.

Let's review the four steps in detail.

1. Plan: Define the goal and the plan for achieving that goal.2. Do/Execute: Depending on the plan strategy decided during the plan stage we do

execution accordingly in this phase.3. Check: Check/Test to ensure that we are moving according to plan and are getting the

desired results.4. Act: During the check cycle, if any issues are there, then we take appropriate action

accordingly and revise our plan again.

So developers and other stakeholders of the project do the "planning and building," while testers do the check part of the cycle. Therefore, software testing is done in check part of the PDCA cyle.

2. What is the difference between white box, black box, and gray box testing?

Black box testing is a testing strategy based solely on requirements and specifications. Black box testing requires no knowledge of internal paths, structures, or implementation of the software being tested.

White box testing is a testing strategy based on internal paths, code structures, and implementation of the software being tested. White box testing generally requires detailed programming skills.

There is one more type of testing called gray box testing. In this we look into the "box" being tested just long enough to understand how it has been implemented. Then we close up the box and use our knowledge to choose more effective black box tests.

2 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 3: General technical interview questions

The above figure shows how both types of testers view an accounting application during testing. Black box testers view the basic accounting application. While during white box testing the tester knows the internal structure of the application. In most scenarios white box testing is done by developers as they know the internals of the application. In black box testing we check the overall functionality of the application while in white box testing we do code reviews, view the architecture, remove bad code practices, and do component level testing.

3. Can you explain usability testing?

Usability testing is a testing methodology where the end customer is asked to use the software to see if the product is easy to use, to see the customer's perception and task time. The best way to finalize the customer point of view for usability is by using prototype or mock-up software during the initial stages. By giving the customer the prototype before the development start-up we confirm that we are not missing anything from the user point of view.

4. What are the categories of defects?

There are three main categories of defects:

1. Wrong: The requirements have been implemented incorrectly. This defect is a variance from the given specification.

3 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 4: General technical interview questions

2. Missing: There was a requirement given by the customer and it was not done. This is a variance from the specifications, an indication that a specification was not implemented, or a requirement of the customer was not noted properly.

3. Extra: A requirement incorporated into the product that was not given by the end customer. This is always a variance from the specification, but may be an attribute desired by the user of the product. However, it is considered a defect because it's a variance from the existing requirements.

5. How do you define a testing policy?

The following are the important steps used to define a testing policy in general. But it can change according to your organization. Let's discuss in detail the steps of implementing a testing policy in an organization.

Definition: The first step any organization needs to do is define one unique definition for testing within the organization so that everyone is of the same mindset.

How to achieve: How are we going to achieve our objective? Is there going to be a testing committee, will there be compulsory test plans which need to be executed, etc?.

Evaluate: After testing is implemented in a project how do we evaluate it? Are we going to derive metrics of defects per phase, per programmer, etc. Finally, it's important to let everyone know how testing has added value to the project?.

Standards: Finally, what are the standards we want to achieve by testing? For instance, we can say that more than 20 defects per KLOC will be considered below standard and code review should be done for it.

6. On what basis is the acceptance plan prepared?

In any project the acceptance document is normally prepared using the following inputs. This can vary from company to company and from project to project.

1. Requirement document: This document specifies what exactly is needed in the project from the customers perspective.

2. Input from customer: This can be discussions, informal talks, emails, etc.

4 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 5: General technical interview questions

3. Project plan: The project plan prepared by the project manager also serves as good input to finalize your acceptance test.

The following diagram shows the most common inputs used to prepare acceptance test plans.

7. What is configuration management?

Configuration management is the detailed recording and updating of information for hardware and software components. When we say components we not only mean source code. It can be tracking of changes for software documents such as requirement, design, test cases, etc.

When changes are done in adhoc and in an uncontrolled manner chaotic situations can arise and more defects injected. So whenever changes are done it should be done in a controlled fashion and with proper versioning. At any moment of time we should be able to revert back to the old version. The main intention of configuration management is to track our changes if we have issues with the current system. Configuration management is done using baselines.

8. How does a coverage tool work?

While doing testing on the actual product, the code coverage testing tool is run simultaneously. While the testing is going on, the code coverage tool monitors the executed statements of the source code. When the final testing is completed we get a complete report of the pending statements and also get the coverage percentage.

9. Which is the best testing model?

5 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 6: General technical interview questions

In real projects, tailored models are proven to be the best, because they share features from The Waterfall, Iterative, Evolutionary models, etc., and can fit into real life time projects. Tailored models are most productive and beneficial for many organizations. If it's a pure testing project, then the V model is the best.

10. What is the difference between a defect and a failure?

When a defect reaches the end customer it is called a failure and if the defect is detected internally and resolved it's called a defect.

11. Should testing be done only after the build and execution phases are complete?

In traditional testing methodology testing is always done after the build and execution phases. 

But that's a wrong way of thinking because the earlier we catch a defect, the more cost effective it is. For instance, fixing a defect in maintenance is ten times more costly than fixing it during execution.

In the requirement phase we can verify if the requirements are met according to the customer needs. During design we can check whether the design document covers all the requirements. In this stage we can also generate rough functional data. We can also review the design document from the architecture and the correctness perspectives. In the build and execution phase we can execute unit test cases and generate structural and functional data. And finally comes the testing phase done in the traditional way. i.e., run the system test cases and see if the system works according to the requirements. During installation we need to see if the system is compatible with the software. Finally, during the maintenance phase when any fixes are made we can retest the fixes and follow the regression testing.

Therefore, Testing should occur in conjunction with each phase of the software development.

12. Are there more defects in the design phase or in the coding phase?

The design phase is more error prone than the execution phase. One of the most frequent defects which occur during design is that the product does not cover the complete requirements of the customer. Second is wrong or bad architecture and technical decisions make the next phase, execution, more prone to defects. Because the design phase drives the execution phase it's the

6 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 7: General technical interview questions

most critical phase to test. The testing of the design phase can be done by good review. On average, 60% of defects occur during design and 40% during the execution phase.

13. What group of teams can do software testing?

When it comes to testing everyone in the world can be involved right from the developer to the project manager to the customer. But below are different types of team groups which can be present in a project.

Isolated test team Outsource - we can hire external testing resources and do testing for our project. Inside test team Developers as testers QA/QC team.

14. What impact ratings have you used in your projects?

Normally, the impact ratings for defects are classified into three types:

 

Minor: Very low impact but does not affect operations on a large scale. Major: Affects operations on a very large scale. Critical: Brings the system to a halt and stops the show.

15. Does an increase in testing always improve the project?

No an increase in testing does not always mean improvement of the product, company, or project. In real test scenarios only 20% of test plans are critical from a business angle. Running those critical test plans will assure that the testing is properly done. The following graph explains the impact of under testing and over testing. If you under test a system the number of defects will

7 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 8: General technical interview questions

increase, but if you over test a system your cost of testing will increase. Even if your defects come down your cost of testing has gone up.

16. What's the relationship between environment reality and test phases?

Environment reality becomes more important as test phases start moving ahead. For instance, during unit testing you need the environment to be partly real, but at the acceptance phase you should have a 100% real environment, or we can say it should be the actual real environment. The following graph shows how with every phase the environment reality should also increase and finally during acceptance it should be 100% real.

17. What are different types of verifications?

Verification is static type of s/w testing. It means code is not executed. The product is evaluated by going through the code. Types of verification are:

1. Walkthrough: Walkthroughs are informal, initiated by the author of the s/w product to a colleague for assistance in locating defects or suggestions for improvements. They are usually unplanned. Author explains the product; colleague comes out with observations and author notes down relevant points and takes corrective actions.

2. Inspection: Inspection is a thorough word-by-word checking of a software product with the intention of Locating defects, Confirming traceability of relevant requirements etc.

18. How do test documents in a project span across the software development lifecycle?

The following figure shows pictorially how test documents span across the software development lifecycle. The following discusses the specific testing documents in the lifecycle:

8 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 9: General technical interview questions

Central/Project test plan: This is the main test plan which outlines the complete test strategy of the software project. This document should be prepared before the start of the project and is used until the end of the software development lifecycle.

Acceptance test plan: This test plan is normally prepared with the end customer. This document commences during the requirement phase and is completed at final delivery.

System test plan: This test plan starts during the design phase and proceeds until the end of the project.

Integration and unit test plan: Both of these test plans start during the execution phase and continue until the final delivery.

19. Which test cases are written first: white boxes or black boxes? Normally black box test cases are written first and white box test cases later. In order to

write black box test cases we need the requirement document and, design or project plan. All these documents are easily available at the initial start of the project. White box test cases cannot be started in the initial phase of the project because they need more architecture clarity which is not available at the start of the project. So normally white box test cases are written after black box test cases are written. 

Black box test cases do not require system understanding but white box testing needs more structural understanding. And structural understanding is clearer i00n the later part of project, i.e., while executing or designing. For black box testing you need to only analyze from the functional perspective which is easily available from a simple requirement document.

20. Explain Unit Testing, Integration Tests, System Testing and Acceptance Testing?

9 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 10: General technical interview questions

Unit testing - Testing performed on a single, stand-alone module or unit of code.

Integration Tests - Testing performed on groups of modules to ensure that data and control are passed properly between modules.

System testing - Testing a predetermined combination of tests that, when executed successfully meets requirements.

Acceptance testing - Testing to ensure that the system meets the needs of the organization and the end user or customer (i.e., validates that the right system was built).

21. What is a test log? The IEEE Std. 829-1998 defines a test log as a chronological record of relevant details

about the execution of test cases. It's a detailed view of activity and events given in chronological manner. 

The following figure shows a test log and is followed by a sample test log.

22. Can you explain requirement traceability and its importance? In most organizations testing only starts after the execution/coding phase of the project.

But if the organization wants to really benefit from testing, then testers should get involved right from the requirement phase.

If the tester gets involved right from the requirement phase then requirement traceability is one of the important reports that can detail what kind of test coverage the test cases have.

23. What does entry and exit criteria mean in a project? Entry and exit criteria are a must for the success of any project. If you do not know where

to start and where to finish then your goals are not clear. By defining exit and entry criteria you define your boundaries.

For instance, you can define entry criteria that the customer should provide the requirement document or acceptance plan. If this entry criteria is not met then you will not start the project. On the other end, you can also define exit criteria for your project. For instance, one of the common exit criteria in projects is that the customer has successfully executed the acceptance test plan.

10 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 11: General technical interview questions

24. What is the difference between verification and validation? Verification is a review without actually executing the process while validation is checking

the product with actual execution. For instance, code review and syntax check is verification while actually running the product and checking the results is validation.

25. What is the difference between latent and masked defects?

A latent defect is an existing defect that has not yet caused a failure because the sets of conditions were never met.

A masked defect is an existing defect that hasn't yet caused a failure just because another defect has prevented that part of the code from being executed.

26. Can you explain calibration?

It includes tracing the accuracy of the devices used in the production, development and testing. Devices used must be maintained and calibrated to ensure that it is working in good order.

27. What's the difference between alpha and beta testing?

Alpha and beta testing has different meanings to different people. Alpha testing is the acceptance testing done at the development site. Some organizations have a different visualization of alpha testing. They consider alpha testing as testing which is conducted on early, unstable versions of software. On the contrary beta testing is acceptance testing conducted at the customer end.

In short, the difference between beta testing and alpha testing is the location where the tests are done.

28. How does testing affect risk?

A risk is a condition that can result in a loss. Risk can only be controlled in different scenarios but not eliminated completely. A defect normally converts to a risk.

11 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 12: General technical interview questions

29. What is coverage and what are the different types of coverage techniques?

Coverage is a measurement used in software testing to describe the degree to which the source code is tested. There are three basic types of coverage techniques as shown in the following figure:

Statement coverage: This coverage ensures that each line of source code has been executed and tested.

Decision coverage: This coverage ensures that every decision (true/false) in the source code has been executed and tested.

Path coverage: In this coverage we ensure that every possible route through a given part of code is executed and tested.

30. A defect which could have been removed during the initial stage is removed in a later stage. How does this affect cost?

If a defect is known at the initial stage then it should be removed during that stage/phase itself rather than at some later stage. It's a recorded fact that if a defect is delayed for later phases it proves more costly. The following figure shows how a defect is costly as the phases move forward. A defect if identified and removed during the requirement and design phase is the most cost effective, while a defect removed during maintenance is 20 times costlier than during the requirement and design phases. 

12 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 13: General technical interview questions

For instance, if a defect is identified during requirement and design we only need to change the documentation, but if identified during the maintenance phase we not only need to fix the defect, but also change our test plans, do regression testing, and change all documentation. This is why a defect should be identified/removed in earlier phases and the testing department should be involved right from the requirement phase and not after the execution phase.

31. What kind of input do we need from the end user to begin proper testing?

The product has to be used by the user. He is the most important person as he has more interest than anyone else in the project. 

From the user we need the following data:

The first thing we need is the acceptance test plan from the end user. The acceptance test defines the entire test which the product has to pass so that it can go into production.

13 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 14: General technical interview questions

We also need the requirement document from the customer. In normal scenarios the customer never writes a formal document until he is really sure of his requirements. But at some point the customer should sign saying yes this is what he wants.

The customer should also define the risky sections of the project. For instance, in a normal accounting project if a voucher entry screen does not work that will stop the accounting functionality completely. But if reports are not derived the accounting department can use it for some time. The customer is the right person to say which section will affect him the most. With this feedback the testers can prepare a proper test plan for those areas and test it thoroughly.

The customer should also provide proper data for testing. Feeding proper data during testing is very important. In many scenarios testers key in wrong data and expect results which are of no interest to the customer.

32. Can you explain the workbench concept?

In order to understand testing methodology we need to understand the workbench concept. A Workbench is a way of documenting how a specific activity has to be performed. A workbench is referred to as phases, steps, and tasks as shown in the following figure.

There are five tasks for every workbench:

Input: Every task needs some defined input and entrance criteria. So for every workbench we need defined inputs. Input forms the first steps of the workbench.

Execute: This is the main task of the workbench which will transform the input into the expected output.

Check: Check steps assure that the output after execution meets the desired result. Production output: If the check is right the production output forms the exit criteria of

the workbench. Rework: During the check step if the output is not as desired then we need to again start

from the execute step.

14 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 15: General technical interview questions

33. Can you explain the concept of defect cascading?

Defect cascading is a defect which is caused by another defect. One defect triggers the other defect. For instance, in the accounting application shown here there is a defect which leads to negative taxation. So the negative taxation defect affects the ledger which in turn affects four other modules.

15 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 16: General technical interview questions

34. Can you explain cohabiting software?

When we install the application at the end client it is very possible that on the same PC other applications also exist. It is also very possible that those applications share common DLLs, resources etc., with your application. There is a huge chance in such situations that your changes can affect the cohabiting software. So the best practice is after you install your application or after any changes, tell other application owners to run a test cycle on their application.

35. What is the difference between pilot and beta testing?

The difference between pilot and beta testing is that pilot testing is nothing but actually using the product (limited to some users) and in beta testing we do not input real data, but it's installed at the end customer to validate if the product can be used in production. 

36. What are the different strategies for rollout to end users?

There are four major ways of rolling out any project:

16 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 17: General technical interview questions

Pilot: The actual production system is installed at a single or limited number of users. Pilot basically means that the product is actually rolled out to limited users for real work.

Gradual Implementation: In this implementation we ship the entire product to the limited users or all users at the customer end. Here, the developers get instant feedback from the recipients which allow them to make changes before the product is available. But the downside is that developers and testers maintain more than one version at one time.

Phased Implementation: In this implementation the product is rolled out to all users in incrementally. That means each successive rollout has some added functionality. So as new functionality comes in, new installations occur and the customer tests them progressively. The benefit of this kind of rollout is that customers can start using the functionality and provide valuable feedback progressively. The only issue here is that with each rollout and added functionality the integration becomes more complicated.

Parallel Implementation: In these types of rollouts the existing application is run side by side with the new application. If there are any issues with the new application we again move back to the old application. One of the biggest problems with parallel implementation is we need extra hardware, software, and resources.

37. What's the difference between System testing and Acceptance testing? Acceptance testing checks the system against the "Requirements." It is similar to System

testing in that the whole system is checked but the important difference is the change in focus:

System testing checks that the system that was specified has been delivered. Acceptance testing checks that the system will deliver what was requested. The customer should always do Acceptance testing and not the developer.

The customer knows what is required from the system to achieve value in the business and is the only person qualified to make that judgement. This testing is more about ensuring that the software is delivered as defined by the customer. It's like getting a green light from the customer that the software meets expectations and is ready to be used.

38. Can you explain regression testing and confirmation testing? Regression testing is used for regression defects. Regression defects are defects occur

when the functionality which was once working normally has stopped working. This is probably because of changes made in the program or the environment. To uncover such kind of defect regression testing is conducted. 

The following figure shows the difference between regression and confirmation testing. 

If we fix a defect in an existing application we use confirmation testing to test if the defect is removed. It's very possible because of this defect or changes to the application that other sections of the application are affected. So to ensure that no other section is affected we can use regression testing to confirm this.

17 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 18: General technical interview questions

Testing Techniques

1. Can you explain boundary value analysis?

In some projects there are scenarios where we need to do boundary value testing. For instance, let's say for a bank application you can withdraw a maximum of 25000 and a minimum of 100. So in boundary value testing we only test the exact boundaries rather than hitting in the middle. That means we only test above the max and below the max. This covers all scenarios. The following figure shows the boundary value testing for the bank application which we just described. TC1 and TC2 are sufficient to test all conditions for the bank. TC3 and TC4 are just duplicate/redundant test cases which really do not add any value to the testing. So by applying proper boundary value fundamentals we can avoid duplicate test cases, which do not add value to the testing.

2. Can you explain equivalence partitioning?

In equivalence partitioning we identify inputs which are treated by the system in the same way and produce the same results. You can see from the following figure applications TC1 and TC2 give the same results (i.e., TC3 and TC4 both give the same result, Result2). In short, we have two redundant test cases. By applying equivalence partitioning we minimize the redundant test cases.

So apply the test below to see if it forms an equivalence class or not:

All the test cases should test the same thing. They should produce the same results.

18 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 19: General technical interview questions

If one test case catches a bug, then the other should also catch it. If one of them does not catch the defect, then the other should not catch it.

3. Can you explain random/monkey testing?

Random testing is sometimes called monkey testing. In Random testing, data is generated randomly often using a tool. For instance, the following figure shows how randomly-generated data is sent to the system. This data is generated either using a tool or some automated mechanism. With this randomly generated input the system is then tested and results are observed accordingly.

Random testing has the following weakness:

They are not realistic. Many of the tests are redundant and unrealistic. You will spend more time analyzing results. You cannot recreate the test if you do not record what data was used for testing.

This kind of testing is really of no use and is normally performed by newcomers. Its best use is to see if the system will hold up under adverse effects.

4. What are semi-random test cases?

As the name specifies semi-random testing is nothing but controlling random testing and removing redundant test cases. So what we do is perform random test cases and equivalence partitioning to those test cases, which in turn removes redundant test cases, thus giving us semi-random test cases.

19 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 20: General technical interview questions

5. Can you explain a pair-wise defect?

Orthogonal array is a two-dimensional array in which if we choose any two columns in the array and all the combinations of numbers will appear in those columns. The following figure shows a simple L9(34) orthogonal array. In this the number 9 indicates that it has 9 rows. The number 4 indicates that it has 4 columns and 3 indicates that each cell contains a 1, 2, and 3. Choose any two columns. Let's choose column 1 and 2. It has (1,1), (1,2), (1,3), (2,1), (2,2), (2,3), (3,1), (3,2), (3,3) combination values. As you can see these values cover all the values in the array. Compare the values with the combination of column 3 and 4 and they will fall in some pair. This is applied in software testing which helps us eliminate duplicate test cases.

6. What is negative and positive testing?

A negative test is when you put in an invalid input and receive errors.

A positive test is when you put in a valid input and expect some action to be completed in accordance with the specification.

7. How did you define severity ratings in your project?

20 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 21: General technical interview questions

There are four types of severity ratings as shown in the table:

Severity 1 (showstoppers): These kinds of defects do not allow the application to move ahead. So they are also called showstopper defects.

Severity 2 (application continues with severe defects): Application continues working with these types of defects, but they can have high implications, later, which can be more difficult to remove.

Severity 3 (application continues with unexpected results): In this scenario the application continues but with unexpected results.

Severity 4 (suggestions): Defects with these severities are suggestions given by the customer to make the application better. These kinds of defects have the least priority and are considered at the end of the project or during the maintenance stage of the project.

8. Can you explain exploratory testing?

Exploratory testing is also called adhoc testing, but in reality it's not completely adhoc. Ad hoc testing is an unplanned, unstructured, may be even an impulsive journey through the system with the intent of finding bugs. Exploratory testing is simultaneous learning, test design, and test execution. In other words, exploratory testing is any testing done to the extent that the tester proactively controls the design of the tests as those tests are performed and uses information gained while testing to design better tests. Exploratory testers are not merely keying in random data, but rather testing areas that their experience (or imagination) tells them are important and then going where those tests take them.

21 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 22: General technical interview questions

9. Can you explain decision tables?

As the name suggests they are tables that list all possible inputs and all possible outputs. A general form of decision table is shown in the following figure. 

Condition 1 through Condition N indicates various input conditions. Action 1 through Condition N are actions that should be taken depending on various input combinations. Each rule defines unique combinations of conditions that result in actions associated with that rule.

22 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 23: General technical interview questions

The Software Process  

1. What is a software process?

A software process is a series of steps used to solve a problem. The following figure shows a pictorial view of how an organization has defined a way to solve risk problems. In the diagram we have shown two branches: one is the process and the second branch shows a sample risk mitigation process for an organization. For instance, the risk mitigation process defines what step any department should follow to mitigate a risk. The process is as follows:

Identify the risk of the project by discussion, proper requirement gathering, and forecasting.

Once you have identified the risk prioritize which risk has the most impact and should be tackled on a priority basis.

Analyze how the risk can be solved by proper impact analysis and planning. Finally, using the above analysis, we mitigate the risk.

2. What are the different cost elements involved in implementing a process in an organization?

23 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 24: General technical interview questions

Below are some of the cost elements involved in the implementing process:

 

Salary: This forms the major component of implementing any process, the salary of the employees. Normally while implementing a process in a company either organization can recruit full-time people or they can share resources part-time for implementing the process.

Consultant: If the process is new it can also involve consultants which are again an added cost.

Training Costs: Employees of the company may also have to undergo training in order to implement the new process

Tools: In order to implement the process an organization will also need to buy tools which again need to be budgeted for.

3. What is a maturity level?

A maturity level specifies the level of performance expected from an organization.

4. What is a model?

A model is nothing but best practices followed in an industry to solve issues and problems. Models are not made in a day but are finalized and realized by years of experience and continuous improvements.

24 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 25: General technical interview questions

Many companies reinvent the wheel rather than following time tested models in the industry.

5. Can you explain process areas in CMMI?

A process area is the area of improvement defined by CMMI. Every maturity level consists of process areas. A process area is a group of practices or activities performed collectively to achieve a specific objective. For instance, you can see from the following figure we have process areas such as project planning, configuration management, and requirement gathering.

6. Can you explain tailoring?

As the name suggests, tailoring is nothing but changing an action to achieve an objective according to conditions. Whenever tailoring is done there should be adequate reasons for it. Remember when a process is defined in an organization it should be followed properly. So even if tailoring is applied the process is not bypassed or omitted.

25 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 26: General technical interview questions

CMMI 

1. What is CMMI and what's the advantage of implementing it in an organization?

CMMI stands for Capability Maturity Model Integration. It is a process improvement approach that provides companies with the essential elements of an effective process. CMMI can serve as a good guide for process improvement across a project, organization, or division.CMMI was formed by using multiple previous CMM processes. 

The following are the areas which CMMI addresses:

Systems engineering: This covers development of total systems. System engineers concentrate on converting customer needs to product solutions and supports them throughout the product lifecycle.

Software engineering: Software engineers concentrate on the application of systematic, disciplined, and quantifiable approaches to the development, operation, and maintenance of software.

Integrated Product and Process Development (IPPD): Integrated Product and Process Development (IPPD) is a systematic approach that achieves a timely collaboration of relevant stakeholders throughout the life of the product to better satisfy customer needs, expectations, and requirements. This section mostly concentrates on the integration part of the project for different processes. For instance, it's possible that your project is using services of some other third party component. In such situations the integration is a big task itself, and if approached in a systematic manner, can be handled with ease.

Software acquisition: Many times an organization has to acquire products from other organizations. Acquisition is itself a big step for any organization and if not handled in a proper manner means a disaster is sure to happen.

2. What's the difference between implementation and institutionalization?

Both of these concepts are important while implementing a process in any organization. Any new process implemented has to go through these two phases.

26 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 27: General technical interview questions

Implementation: It is just performing a task within a process area. A task is performed according to a process but actions performed to complete the process are not ingrained in the organization. That means the process involved is done according to the individual point of view. When an organization starts to implement any process it first starts at this phase, i.e., implementation, and then when this process looks good it is raised to the organization level so that it can be implemented across organizations. 

Institutionalization: Institutionalization is the output of implementing the process again and again. The difference between implementation and institutionalization is in implementation if the person who implemented the process leaves the company the process is not followed, but if the process is institutionalized then even if the person leaves the organization, the process is still followed.

3. Can you explain the different maturity levels in a staged representation?

There are five maturity levels in a staged representation as shown in the following figure.

Maturity Level 1 (Initial): In this level everything is adhoc. Development is completely chaotic with budget and schedules often exceeded. In this scenario we can never predict quality. 

Maturity Level 2 (Managed): In the managed level basic project management is in place. But the basic project management and practices are followed only in the project level.

Maturity Level 3 (Defined): To reach this level the organization should have already achieved level 2. In the previous level the good practices and process were only done at the project level. But in this level all these good practices and processes are brought to the organization level. There are set and standard practices defined at the organization level which every project should follow. Maturity Level 3 moves ahead with defining a strong, meaningful, organizational approach to developing products. An important distinction between Maturity Levels 2 and 3 is that at Level 3, processes are described in more detail and more rigorously than at Level 2 and are at an organization level.

Maturity Level 4 (Quantitatively measured): To start with, this level of organization should have already achieved Level 2 and Level 3. In this level, more statistics come into the picture. Organization controls the project by statistical and other quantitative techniques. Product quality, process performance, and service quality are understood in statistical terms and are managed throughout the life of the processes. Maturity Level 4 concentrates on using metrics to make decisions and to truly measure whether progress is happening and the product is becoming better. The main difference between Levels 3 and 4 are that at Level 3, processes are qualitatively predictable. At Level 4, processes are quantitatively predictable. Level 4 addresses causes of process variation and takes corrective action.

27 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 28: General technical interview questions

Maturity Level 5 (Optimized): The organization has achieved goals of maturity levels 2, 3, and 4. In this level, processes are continually improved based on an understanding of common causes of variation within the processes. This is like the final level; everyone on the team is a productive member, defects are minimized, and products are delivered on time and within the budget boundary.

The following figure shows, in detail, all the maturity levels in a pictorial fashion.

4. What are the different models in CMMI?

There are two models in CMMI. The first is "staged" in which the maturity level organizes the process areas. 

The second is "continuous" in which the capability level organizes the process area.

5. How is appraisal done in CMMI?

SCAMPI stands for Standard CMMI Appraisal Method for Process Improvement. SCAMPI is an assessment process used to get CMMI certified for an organization. 

There are three classes of CMMI appraisal methods: Class A, Class B, and Class C. Class A is the most aggressive, while Class B is less aggressive, and Class C is the least aggressive.

28 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 29: General technical interview questions

Let's discuss these appraisal methods in more detail.

Class A: This is the only method that can provide a rating and get you a CMMI certificate. It requires all three sources of data instruments, interviews, and documents.

Class B: This class requires only two sources of data (interviews and either documents or instruments). But please note you do not get rated with Class B appraisals. Class B is just a warm-up to see if an organization is ready for Class A. With less verification the appraisal takes less time. In this class data sufficiency and draft presentations are optional.

Class C: This class requires only one source of data (interviews, instruments, or documents). Team consensus, validation, observation, data sufficiency, and draft presentation are optional.

6. Which appraisal method class is best?

Normally, organizations use a mix of the classes to achieve process improvement. The following are some of the strategies which an organization uses:

First Strategy: Use Class B to initiate a process improvement plan, after that apply Class C to check readiness for Class B or Class A. The following diagram shows this strategy.

Second Strategy: Class C appraisal is used on a subset of an organization. From this we get an aggregation of weakness across the organization. From this we can prepare a process improvement plan. We can then apply a Class B appraisal to see if we are ready for Class A appraisal. The following diagram shows the strategy.

29 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 30: General technical interview questions

Third Strategy: Class A is used to initiate an organization level process. The process improvement plan is based on an identified weakness. Class B appraisal should be performed after six months to see the readiness for the second Class A appraisal rating. The following diagram shows this strategy.

7. What different sources are needed to verify authenticity for CMMI implementation?

There are three different sources from which an appraiser can verify that an organization followed the process or not. 

30 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 31: General technical interview questions

Instruments: An instrument is a survey or questionnaire provided to the organization, project, or individuals before starting the assessment so that beforehand the appraiser knows some basic details of the project.

Interview: An interview is a formal meeting between one or more members of the organization in which they are asked some questions and the appraiser makes some judgments based on those interviews. During the interview the member represents some process area or role which he performs. For instance, the appraiser may interview a tester or programmer asking him indirectly what metrics he has submitted to his project manager. By this the appraiser gets a fair idea of CMMI implementation in that organization.

Documents: A document is a written work or product which serves as evidence that a process is followed. It can be hard copy, Word document, email, or any type of written official proof.

The following figure is the pictorial view of the sources used to verify how compliant the organization is with CMMI.

8. Which model should we use and under what scenarios?

Staging defines an organization process implementation sequence. So staging is a sequence of targeted process areas that describe a path of process improvement the organization will take. For instance, you cannot do your project planning (Level 2) if you have not done requirements management (Level 2). While in the continuous model you select certain process areas even if they're linked with other process areas and mature there.

So when your organization should only concentrate on specific process areas you will likely go for the continuous model. But if you want your organization to have a specific plan and to achieve not only the specific process but also any interlinked process within that process area you should go for the continuous model.

9. Can you explain capability levels in a continuous representation?

The continuous model is the same as the staged model only that the arrangement is a bit different. The continuous representation/model concentrates on the action or task to be completed within a process area. It focuses on maturing the organizations ability to perform, control, and improve the performance in that specific performance area.

31 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 32: General technical interview questions

 Capability Level 0 Incomplete: This level means that any generic or specific practice of capability level 1 is not performed.

Capability Level 1: Performed: The capability level 1 process is expected to perform all capability level 1 specific and generic practices for that process area. In this level performance may not be stable and probably does not meet objectives such as quality, cost, and schedule, but still the task can be done.

Capability Level 2: Managed: Capability level 2 is a managed process planned properly, performed, monitored, and controlled to achieve a given purpose. Because the process is managed we achieve other objectives, such as cost, schedule, and quality. Because you are managing, certain metrics are consistently collected and applied to your management approach.

Capability Level 3: Defined: The defined process is a managed process that is tailored from an organization standard. Tailoring is done by justification and documentation guidelines. For instance your organization may have a standard that we should get an invoice from every supplier. But if the supplier is not able to supply the invoice then he should sign an agreement in place of the invoice. So here the invoice standard is not followed but the deviation is under control.

Capability Level 4: Quantitatively Managed: The quantitatively managed process is a defined process which is controlled through statistical and quantitative information. So from defect tracking to project schedules all are statistically tracked and measured for that process.

Capability Level 5: Optimizing: The optimizing process is a quantitatively managed process where we increase process performance through incremental and innovative improvements. 

Continuous representation is the same as staged only that information is arranged in a different fashion. The biggest difference is one concentrates on a specific process while the other brings a group of processes to a certain maturity level.

32 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 33: General technical interview questions

Six Sigma

1. What is Six Sigma?

Six Sigma is a statistical measure of variation in a process. We say a process has achieved Six Sigma if the quality is 3.4 DPMO (Defect per Million Opportunities). It's a problem-solving methodology that can be applied to a process to eliminate the root cause of defects and costs associated with it.

2. Can you explain the different methodology for the execution and the design process stages in Six Sigma?

The main focus of Six Sigma is to reduce defects and variations in the processes. DMAIC and DMADV are the models used in most Six Sigma initiatives. 

DMADV is the model for designing processes while DMAIC is used for improving the process. 

The DMADV model includes the following five steps:

Define: Determine the project goals and the requirements of customers (external and internal).

Measure: Assess customer needs and specifications. Analyze: Examine process options to meet customer requirements. Design: Develop the process to meet the customer requirements. Verify: Check the design to ensure that it's meeting customer requirements

33 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 34: General technical interview questions

The DMAIC model includes the following five steps:

Define the projects, goals, and deliverables to customers (internal and external). Describe and quantify both the defects and the expected improvements.

Measure the current performance of the process. Validate data to make sure it is credible and set the baselines.

Analyze and determine the root cause(s) of the defects. Narrow the causal factors to the vital few.

Improve the process to eliminate defects. Optimize the vital few and their interrelationships.

Control the performance of the process. Lock down the gains.

3. Can you explain the fish bone/Ishikawa diagram?

There are situations where we need to analyze what caused the failure or problem in a project. The fish bone or Ishikawa diagram is one important concept which can help you find the root cause of the problem. Fish bone was conceptualized by Ishikawa, so in honor of its inventor, this concept was named the Ishikawa diagram. Inputs to conduct a fish bone diagram come from discussion and brainstorming with people involved in the project. The following figure shows the structure of the Ishikawa diagram.

34 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 35: General technical interview questions

The main bone is the problem which we need to address to know what caused the failure. For instance, the following fish bone is constructed to find what caused the project failure. To know this cause we have taken four main bones as inputs: Finance, Process, People, and Tools.

4. What are the different kinds of variations used in Six Sigma?

Variation is the basis of Six Sigma. It defines how many changes are happening in the output of a process. So if a process is improved then this should reduce variations. In Six Sigma we identify variations in the process, control them, and reduce or eliminate defects. 

There are four basic ways of measuring variations: Mean, Median, Mode, and Range.

35 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 36: General technical interview questions

5. Can you explain standard deviation?

The most accurate method of quantifying variation is by using standard deviation. It indicates the degree of variation in a set of measurements or a process by measuring the average spread of data around the mean. It's more complicated than the deviation process discussed in the previous question, but it does give accurate information.

Metrics

1. What is meant by measures and metrics?

Measures are quantitatively unit defined elements, for instance, hours, km, etc. Metrics are basically comprised of more than one measure. For instance, we can have metrics such as km/hr, m/s etc.

2. Can you explain how the number of defects is measured?

36 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 37: General technical interview questions

The number of defects is one of the measures used to measure test effectiveness. One of the side effects of the number of defects is that all bugs are not equal. So it becomes necessary to weight bugs according to their criticality level. If we are using the number of defects as the metric measurement the following are the issues:

The number of bugs that originally existed significantly impacts the number of bugs discovered, which in turns gives a wrong measure of the software quality.

All defects are not equal so defects should be numbered with a criticality level to get the right software quality measure.

3. Can you explain unit and system test DRE?

DRE is also useful to measure the effectiveness of a particular test such as acceptance, unit, or system testing. The following figure shows defect numbers at various software cycle levels. The 1 indicates that defects are input at the phase and2indicates that these many defects were removed from that particular phase. For instance, in the requirement phase 100 defects were present, but 20 defects are removed from the requirement phase due to a code review. So if 20 defects are removed then 80 defects get carried to the new phase (design) and so on.

4. Can you explain DRE?

DRE (Defect Removal Efficiency) is a powerful metric used to measure test effectiveness. From this metric we come to know how many bugs we found from the set of bugs which we could have

37 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 38: General technical interview questions

found. The following is the formula for calculating DRE. We need two inputs for calculating this metric: the number of bugs found during development and the number of defects detected at the end user.

But the success of DRE depends on several factors. The following are some of them:

Severity and distribution of bugs must be taken into account. Second, how do we confirm when the customer has found all the bugs. This is normally

achieved by looking at the history of the customer.

5. Can you explain defect age and defect spoilage?

Defect age is also called a phase age or phage. One of the most important things to remember in testing is that the later we find a defect the more it costs to fix it. Defect age and defect spoilage metrics work with the same fundamental, i.e., how late you found the defect. So the first thing we need to define is what is the scale of the defect age according to phases. For instance, the following table defines the scale according to phases. So, for instance, requirement defects, if found in the design phase, have a scale of 1, and the same defect, if propagated until the production phase, goes up to a scale of 4.

Once the scale is decided now we can find the defect spoilage. Defect spoilage is defects from the previous phase multiplied by the scale. For instance, in the following figure we have found 8 defects in the design phase from which 4 defects are propagated from the requirement phase. So we multiply the 4 defects with the scale defined in the previous table, so we get the value of 4. In the same fashion we calculate for all the phases. The following is the spoilage formula.

38 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 39: General technical interview questions

6. Can you explain how the number of production defects is measured?

This is one of the most effective measures. The number of defects found in a production is recorded. The only issue with this measure is it can have latent and masked defects which can give us the wrong value regarding software quality.

7. Can you explain defect seeding?

Defect seeding is a technique that was developed to estimate the number of defects resident in a piece of software. It's an offline technique and should not be used by everyone. The process is the following: we inject the application with defects and then see if the defect is found or not. So, for instance, if we have injected 100 defects we try to get three values. First how many seeded defects were discovered, how many were not discovered, and how many new defects (unseeded) are discovered. By using defect seeding we can predict the number of defects remaining in the system.

8. How do you measure test effectiveness?

Test effectiveness is the measure of the bug-finding ability of our tests. In short, it measures how good the tests were. So effectiveness is the ratio of the measure of bugs found during testing to the total bugs found. Total bugs are the sum of new defects found by the user plus the bugs found in the test. The following figure explains the calculations in a pictorial format.

39 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 40: General technical interview questions

Automated Testing

1. Does automation replace manual testing?

Automation is the integration of testing tools into the test environment in such a manner that the test execution, logging, and comparison of results are done with little human intervention. A testing tool is a software application which helps automate the testing process. But the testing tool is not the complete answer for automation. One of the huge mistakes done in testing automation is automating the wrong things during development. Many testers learn the hard way that everything cannot be automated. The best components to automate are repetitive tasks. So some companies first start with manual testing and then see which tests are the most repetitive ones and only those are then automated.

As a rule of thumb do not try to automate:

Unstable software: If the software is still under development and undergoing many changes automation testing will not be that effective.

Once in a blue moon test scripts: Do not automate test scripts which will be run once in a while.

Code and document review: Do not try to automate code and document reviews; they will just cause trouble.

The following figure shows what should not be automated.

40 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 41: General technical interview questions

All repetitive tasks which are frequently used should be automated. For instance, regression tests are prime candidates for automation because they're typically executed many times. Smoke, load, and performance tests are other examples of repetitive tasks that are suitable for automation. White box testing can also be automated using various unit testing tools. Code coverage can also be a good candidate for automation.

2. How does load testing work for websites?

Websites have software called a web server installed on the server. The user sends a request to the web server and receives a response. So, for instance, when you type www.google.com the web server senses it and sends you the home page as a response. This happens each time you click on a link, do a submit, etc. So if we want to do load testing you need to just multiply these requests and responses "N" times. This is what an automation tool does. It first captures the request and response and then just multiplies it by "N" times and sends it to the web server, which results in load simulation.

So once the tool captures the request and response, we just need to multiply the request and response with the virtual user. Virtual users are logical users which actually simulate the actual physical user by sending in the same request and response. If you want to do load testing with 10,000 users on an application it's practically impossible. But by using the load testing tool you only need to create 1000 virtual users.

41 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 42: General technical interview questions

3. Can you explain data-driven testing?

Normally an application has to be tested with multiple sets of data. For instance, a simple login screen, depending on the user type, will give different rights. For example, if the user is an admin he will have full rights, while a user will have limited rights and support if he only has read-only support rights. In this scenario the testing steps are the same but with different user ids and passwords. In data-driven testing, inputs to the system are read from data files such as Excel, CSV (comma separated values), ODBC, etc. So the values are read from these sources and then test steps are executed by automated testing.

42 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 43: General technical interview questions

Testing Estimation 

1. What are the different Ways of doing Black Box testing?

There are five methodologies most frequently used:

1. Top down according to budget2. WBS (Work Breakdown Structure)3. Guess and gut feeling4. Early project data5. TPA (Test Point Analysis)

2. Can you explain TPA analysis?

TPA is a technique used to estimate test efforts for black box testing. Inputs for TPA are the counts derived from function points.

Below are the features of TPA:

Used to estimate only black box testing. Require function points as inputs.

3. Can you explain the elementary process?

Software applications are a combination of elementary processes. When elementary processes come together they form a software application.

There are two types of elementary processes:

1. Dynamic elementary Process: The dynamic elementary process moves data from an internal application boundary to an external application boundary or vice-versa. Example: Input data screen where a user inputs data into the application. Data moves from the input screen inside the application.

2. Static elementary Process: Static elementary process which maintains the data of the application either inside the application boundary or in the external application boundary.

43 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 44: General technical interview questions

For example, in a customer maintenance screen maintaining customer data is a static elementary process.

4. How do you estimate white box testing?

The testing estimates derived from function points are actually the estimates for white box testing. So in the following figure the man days are actually the estimates for white box testing of the project. It does not take into account black box testing estimation.

5. Can you explain the various elements of function points FTR, ILF, EIF, EI, EO, EQ, and GSC?

File Type References (FTRs): An FTR is a file or data referenced by a transaction. An FTR should be an ILF or EIF. So count each ILF or EIF read during the process. If the EP is maintained as an ILF then count that as an FTR. So by default you will always have one FTR in any EP.

Internal Logical Files (ILFs): ILFs are logically related data from a user's point of view. They reside in the internal application boundary and are maintained through the elementary process of the application.ILFs can have a maintenance screen but not always.

External Interface Files (EIFs): EIFs reside in the external application boundary. EIFs are used only for reference purposes and are not maintained by internal applications. EIFs are maintained by external applications.

External Input (EI): EIs are dynamic elementary processes in which data is received from the external application boundary. Example: User interaction screens, when data comes from the User Interface to the Internal Application.

External Output (EO): EOs are dynamic elementary processes in which derived data crosses from the internal application boundary to the external application boundary.

External Inquiry (EQ): An EQ is a dynamic elementary process in which result data is retrieved from one or more ILF or EIF. In this EP some input requests have to enter the application boundary. Output results exits the application boundary.

General System Characteristics (GSCs): This section is the most important section. All the previously discussed sections relate only to applications. But there are other things also to be considered while making software, such as are you going to make it an N-Tier application, what's the performance level the user is expecting, etc. These other factors are called GSCs.

6. Can you explain an Application boundary?

The first step in FPA is to define the boundary. There are two types of major boundaries:

1. Internal Application Boundary2. External Application Boundary

The external application boundary can be identified using the following litmus test:

1. Does it have or will it have any other interface to maintain its data, which was not developed by you?.

2. Does your program have to go through a third party API or layer? In order for your application to interact with the tax department application your code has to interact with the tax department API.

44 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 45: General technical interview questions

3. The best litmus test is to ask yourself if you have full access to the system. If you have full rights to make changes then it is an internal application boundary, otherwise it is an external application boundary.

7. Can you explain how TPA works?

There are three main elements which determine estimates for black box testing: size, test strategy, and productivity. Using all three elements we can determine the estimate for black box testing for a given project. Let's take a look at these elements.

1. Size: The most important aspect of estimating is definitely the size of the project. The size of a project is mainly defined by the number of function points. But a function point fails or pays the least attention to the following factors:

1. Complexity: Complexity defines how many conditions exist in function points identified during a project. More conditions means more test cases which means more testing

45 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 46: General technical interview questions

estimates. 

2. Interfacing: How much does one function affect the other part of the system? If a function is modified then accordingly the other systems have to be tested as one function always impacts another.

3. Uniformity: How reusable is the application? It is important to consider how many similar structured functions exist in the system. It is important to consider the extent to which the system allows testing with slight modifications.

2. Test strategy: Every project has certain requirements. The importance of all these requirements also affects testing estimates. Any requirement importance is from two perspectives: one is the user importance and the other is the user usage. Depending on these two characteristics a requirement rating can be generated and a strategy can be chalked out accordingly, which also means that estimates vary accordingly. 

46 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 47: General technical interview questions

3. Productivity: This is one more important aspect to be considered while estimating black box testing. Productivity depends on many

aspects. 

8. Can you explain steps in function points?

Below are the steps in function points:

1. First Count ILF, EIF, EI, EQ, RET, DET, FTR and use the rating tables. After you have counted all the elements you will get the unadjusted function points.

2. Put rating values 0 to 5 to all 14 GSC. Adding total of all 14 GSC to come out with total VAF. Formula for VAF = 0.65 + (sum of all GSC factor/100).

3. Finally, make the calculation of adjusted function point. Formula: Total function point = VAF * Unadjusted function point.

4. Make estimation how many function points you will do per day. This is also called as "Performance factor".On basis of performance factor, you can calculate Man/Days.

9. Can you explain function points?

Function points are a unit measure for software much like an hour is to measuring time, miles are to measuring distance or Celsius is to measuring temperature. Function Points are an ordinal measure much like other measures such as kilometers, Fahrenheit, hours, so on and so forth.

This approach computes the total function points (FP) value for the project, by totaling the number of external user inputs, inquiries, outputs, and master files, and then applying the following weights: inputs (4), outputs (5), inquiries (4), and master files (10). Each FP contributor can be adjusted within a range of +/-35% for a specific project complexity.

Data Structures 

47 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 48: General technical interview questions

1. What is data structure?

A data structure is a way of organizing data that considers not only the items stored, but also their relationship to each other. Advance knowledge about the relationship between data items allows designing of efficient algorithms for the manipulation of data.

2. List out the areas in which data structures are applied extensively?

1. Compiler Design,2. Operating System,3. Database Management System,4. Statistical analysis package,5. Numerical Analysis,6. Graphics,7. Artificial Intelligence,8. Simulation

3. What are the major data structures used in the following areas : RDBMS, Network data model and Hierarchical data model.

1. RDBMS = Array (i.e. Array of structures)2. Network data model = Graph3. Hierarchical data model = Trees

4. If you are using C language to implement the heterogeneous linked list, what pointer type will you use?

The heterogeneous linked list contains different data types in its nodes and we need a link, pointer to connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Void pointer is capable of storing pointer to any type as it is a generic pointer type.

5. Minimum number of queues needed to implement the priority queue?

Two. One queue is used for actual storing of data and another for storing priorities.

6. What is the data structures used to perform recursion?

Stack. Because of its LIFO (Last In First Out) property it remembers its 'caller' so knows whom to return when the function has to return. Recursion makes use of system stack for storing the return addresses of the function calls.

Every recursive function has its equivalent iterative (non-recursive) function. Even when such equivalent iterative procedures are written, explicit stack is to be used.

7. What are the notations used in Evaluation of Arithmetic Expressions using prefix and postfix forms?

Polish and Reverse Polish notations.

8. Convert the expression ((A + B) * C - (D - E) ^ (F + G)) to equivalent Prefix and Postfix notations.

48 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 49: General technical interview questions

1. Prefix Notation: - * +ABC ^ - DE + FG2. Postfix Notation: AB + C * DE - FG + ^ -

9. Sorting is not possible by using which of the following methods? (Insertion, Selection, Exchange, Deletion)

Sorting is not possible in Deletion. Using insertion we can perform insertion sort, using selection we can perform selection sort, using exchange we can perform the bubble sort (and other similar sorting methods). But no sorting method can be done just using deletion.

10. What are the methods available in storing sequential files ?

1. Straight merging,2. Natural merging,3. Polyphase sort,4. Distribution of Initial runs.

11. List out few of the Application of tree data-structure?

1. The manipulation of Arithmetic expression,2. Symbol Table construction,3. Syntax analysis.

12. List out few of the applications that make use of Multilinked Structures?

1. Sparse matrix,2. Index generation.

13. In tree construction which is the suitable efficient data structure? (Array, Linked list, Stack, Queue)

Linked list is the suitable efficient data structure.

14. What is the type of the algorithm used in solving the 8 Queens problem?

Backtracking.

15. In an AVL tree, at what condition the balancing is to be done?

If the 'pivotal value' (or the 'Height factor') is greater than 1 or less than -1.

16. What is the bucket size, when the overlapping and collision occur at same time?

One. If there is only one entry possible in the bucket, when the collision occurs, there is no way to accommodate the colliding value. This results in the overlapping of values.

17. Classify the Hashing Functions based on the various methods by which the key value is found.

1. Direct method,2. Subtraction method,

49 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 50: General technical interview questions

3. Modulo-Division method,4. Digit-Extraction method,5. Mid-Square method,6. Folding method,7. Pseudo-random method.

18. What are the types of Collision Resolution Techniques and the methods used in each of the type?

1. Open addressing (closed hashing), The methods used include: Overflow block.2. Closed addressing (open hashing), The methods used include: Linked list, Binary tree.

19. In RDBMS, what is the efficient data structure used in the internal storage representation?

B+ tree. Because in B+ tree, all the data is stored only in leaf nodes, that makes searching easier. This corresponds to the records that shall be stored in leaf nodes.

20. What is a spanning Tree?

A spanning tree is a tree associated with a network. All the nodes of the graph appear on the tree once. A minimum spanning tree is a spanning tree organized so that the total edge weight between nodes is minimized.

21. Does the minimum spanning tree of a graph give the shortest distance between any 2 specified nodes?

No. The Minimal spanning tree assures that the total weight of the tree is kept at its minimum. But it doesn't mean that the distance between any two nodes involved in the minimum-spanning tree is minimum.

22. Which is the simplest file structure? (Sequential, Indexed, Random)

Sequential is the simplest file structure.

23. Whether Linked List is linear or Non-linear data structure?

According to Access strategies Linked list is a linear one. According to Storage Linked List is a Non-linear one.

The C Language Basics

1. What is a local block?

A local block is any portion of a C program that is enclosed by the left brace ({) and the right brace (}). A C function contains left and right braces, and therefore anything between the two braces is contained in a local block. An if statement or a switch statement can also contain braces, so the portion of code between these two braces would be considered a local block.

50 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 51: General technical interview questions

Additionally, you might want to create your own local block without the aid of a C function or keyword construct. This is perfectly legal. Variables can be declared within local blocks, but they must be declared only at the beginning of a local block. Variables declared in this manner are visible only within the local block. Duplicate variable names declared within a local block take precedence over variables with the same name declared outside the local block. Here is an example of a program that uses local blocks:

#include <stdio.h>void main(void);void main(){ /* Begin local block for function main() */ int test_var = 10; printf("Test variable before the if statement: %d\n", test_var); if (test_var > 5) { /* Begin local block for "if" statement */ int test_var = 5; printf("Test variable within the if statement: %d\n", test_var); { /* Begin independent local block (not tied to any function or keyword) */ int test_var = 0; printf( "Test variable within the independent local block:%d\n", test_var); } /* End independent local block */ } /* End local block for "if" statement */ printf("Test variable after the if statement: %d\n", test_var);}/* End local block for function main() */

This example program produces the following output:

Test variable before the if statement: 10

Test variable within the if statement: 5

Test variable within the independent local block: 0

Test variable after the if statement: 10

Notice that as each test_var was defined, it took precedence over the previously defined test_var. Also notice that when the if statement local block had ended, the program had reentered the scope of the originaltest_var, and its value was 10.

2. Should variables be stored in local blocks?

51 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 52: General technical interview questions

The use of local blocks for storing variables is unusual and therefore should be avoided, with only rare exceptions. One of these exceptions would be for debugging purposes, when you might want to declare a local instance of a global variable to test within your function. You also might want to use a local block when you want to make your program more readable in the current context.

Sometimes having the variable declared closer to where it is used makes your program more readable. However, well-written programs usually do not have to resort to declaring variables in this manner, and you should avoid using local blocks.

3. When is a switch statement better than multiple if statements?

A switch statement is generally best to use when you have more than two conditional expressions based on a single variable of numeric type. For instance, rather than the code

if (x == 1) printf("x is equal to one.\n");else if (x == 2) printf("x is equal to two.\n");else if (x == 3) printf("x is equal to three.\n");else printf("x is not equal to one, two, or three.\n");

the following code is easier to read and maintain:

switch (x){ case 1: printf("x is equal to one.\n"); break; case 2: printf("x is equal to two.\n"); break; case 3: printf("x is equal to three.\n"); break; default: printf("x is not equal to one, two, or three.\n"); break;}

Notice that for this method to work, the conditional expression must be based on a variable of numeric type in order to use the switch statement. Also, the conditional expression must be based on a single variable. For instance, even though the following if statement contains more than two conditions, it is not a candidate for using a switch statement because it is based on string comparisons and not numeric comparisons:

char* name = "Lupto";if (!stricmp(name, "Isaac")) printf("Your name means 'Laughter'.\n");else if (!stricmp(name, "Amy")) printf("Your name means 'Beloved'.\n ");

52 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 53: General technical interview questions

else if (!stricmp(name, "Lloyd")) printf("Your name means 'Mysterious'.\n ");else printf("I haven't a clue as to what your name means.\n");

4. Is a default case necessary in a switch statement?

No, but it is not a bad idea to put default statements in switch statements for error- or logic-checking purposes. For instance, the following switch statement is perfectly normal:

switch (char_code){ case 'Y': case 'y': printf("You answered YES!\n"); break; case 'N': case 'n': printf("You answered NO!\n"); break;}

Consider, however, what would happen if an unknown character code were passed to this switch statement. The program would not print anything. It would be a good idea, therefore, to insert a default case where this condition would be taken care of:

... default: printf("Unknown response: %d\n", char_code); break;...

Additionally, default cases come in handy for logic checking. For instance, if your switch statement handled a fixed number of conditions and you considered any value outside those conditions to be a logic error, you could insert a default case which would flag that condition. Consider the following example:

void move_cursor(int direction){ switch (direction) { case UP: cursor_up(); break; case DOWN: cursor_down(); break; case LEFT: cursor_left(); break; case RIGHT: cursor_right(); break; default: printf("Logic error on line number %ld!!!\n",

53 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 54: General technical interview questions

__LINE__); break; }}

5. Can the last case of a switch statement skip including the break?

Even though the last case of a switch statement does not require a break statement at the end, you should addbreak statements to all cases of the switch statement, including the last case. You should do so primarily because your program has a strong chance of being maintained by someone other than you who might add cases but neglect to notice that the last case has no break statement.

This oversight would cause what would formerly be the last case statement to "fall through" to the new statements added to the bottom of the switch statement. Putting a break after each case statement would prevent this possible mishap and make your program more "bulletproof." Besides, most of today's optimizing compilers will optimize out the last break, so there will be no performance degradation if you add it.

6. Other than in a for statement, when is the comma operator used?

The comma operator is commonly used to separate variable declarations, function arguments, and expressions, as well as the elements of a for statement. Look closely at the following program, which shows some of the many ways a comma can be used:

#include <stdio.h>#include <stdlib.h>void main(void);void main(){ /* Here, the comma operator is used to separate three variable declarations. */ int i, j, k; /* Notice how you can use the comma operator to perform multiple initializations on the same line. */ i = 0, j = 1, k = 2; printf("i = %d, j = %d, k = %d\n", i, j, k); /* Here, the comma operator is used to execute three expressions in one line: assign k to i, increment j, and increment k. The value that i receives is always the rightmost expression. */ i = (j++, k++); printf("i = %d, j = %d, k = %d\n", i, j, k); /* Here, the while statement uses the comma operator to assign the value of i as well as test it. */ while (i = (rand() % 100), i != 50) printf("i is %d, trying again...\n", i); printf("\nGuess what? i is 50!\n");}

54 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 55: General technical interview questions

Notice the line that reads

i = (j++, k++);

This line actually performs three actions at once. These are the three actions, in order:

1. Assigns the value of k to i. This happens because the left value (lvalue) always evaluates to the rightmost argument. In this case, it evaluates to k. Notice that it does not evaluate to k++, because k++ is a postfix incremental expression, and k is not incremented until the assignment of k to i is made. If the expression had read ++k, the value of ++k would be assigned to i because it is a prefix incremental expression, and it is incremented before the assignment is made.

2. Increments j.

3. Increments k.

Also, notice the strange-looking while statement:

while (i = (rand() % 100), i != 50) printf("i is %d, trying again...\n");

Here, the comma operator separates two expressions, each of which is evaluated for each iteration of the whilestatement. The first expression, to the left of the comma, assigns i to a random number from 0 to 99.

The second expression, which is more commonly found in a while statement, is a conditional expression that tests to see whether i is not equal to 50. For each iteration of the while statement, i is assigned a new random number, and the value of i is checked to see that it is not 50. Eventually, i is randomly assigned the value 50, and the while statement terminates.

7. How can you tell whether a loop ended prematurely?

Generally, loops are dependent on one or more variables. Your program can check those variables outside the loop to ensure that the loop executed properly. For instance, consider the following example:

#define REQUESTED_BLOCKS 512int x;char* cp[REQUESTED_BLOCKS];/* Attempt (in vain, I must add...) to allocate 512 10KB blocks in memory. */for (x=0; x< REQUESTED_BLOCKS; x++){ cp[x] = (char*) malloc(10000, 1); if (cp[x] == (char*) NULL) break;}/* If x is less than REQUESTED_BLOCKS, the loop has ended prematurely. */

55 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 56: General technical interview questions

if (x < REQUESTED_BLOCKS) printf("Bummer! My loop ended prematurely!\n");

Notice that for the loop to execute successfully, it would have had to iterate through 512 times. Immediately following the loop, this condition is tested to see whether the loop ended prematurely. If the variable x is anything less than 512, some error has occurred.

8. What is the difference between goto and long jmp( ) and setjmp()?

A goto statement implements a local jump of program execution, and the longjmp() and setjmp() functions implement a nonlocal, or far, jump of program execution. Generally, a jump in execution of any kind should be avoided because it is not considered good programming practice to use such statements as goto and longjmpin your program.

A goto statement simply bypasses code in your program and jumps to a predefined position. To use the gotostatement, you give it a labeled position to jump to. This predefined position must be within the same function. You cannot implement gotos between functions. Here is an example of a goto statement:

void bad_programmers_function(void){ int x; printf("Excuse me while I count to 5000...\n"); x = 1; while (1) { printf("%d\n", x); if (x == 5000) goto all_done; else x = x + 1; }all_done: printf("Whew! That wasn't so bad, was it?\n");}

This example could have been written much better, avoiding the use of a goto statement. Here is an example of an improved implementation:

void better_function(void){ int x; printf("Excuse me while I count to 5000...\n"); for (x=1; x<=5000; x++) printf("%d\n", x); printf("Whew! That wasn't so bad, was it?\n");}

56 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 57: General technical interview questions

As previously mentioned, the longjmp() and setjmp() functions implement a nonlocal goto. When your program calls setjmp(), the current state of your program is saved in a structure of type jmp_buf. Later, your program can call the longjmp() function to restore the program's state as it was when you called setjmp(). Unlike the goto statement, the longjmp() and setjmp() functions do not need to be implemented in the same function.

However, there is a major drawback to using these functions: your program, when restored to its previously saved state, will lose its references to any dynamically allocated memory between the longjmp() and thesetjmp(). This means you will waste memory for every malloc() or calloc() you have implemented between your longjmp() and setjmp(), and your program will be horribly inefficient. It is highly recommended that you avoid using functions such as longjmp() and setjmp() because they, like the goto statement, are quite often an indication of poor programming practice.

Here is an example of the longjmp() and setjmp() functions:

#include <stdio.h>#include <setjmp.h>jmp_buf saved_state;void main(void);void call_longjmp(void);void main(void){ int ret_code; printf("The current state of the program is being saved...\n"); ret_code = setjmp(saved_state); if (ret_code == 1) { printf("The longjmp function has been called.\n"); printf("The program's previous state has been restored.\n"); exit(0); } printf("I am about to call longjmp and\n"); printf("return to the previous program state...\n"); call_longjmp();}void call_longjmp(void){ longjmp(saved_state, 1);}

9. What is an lvalue?

An lvalue is an expression to which a value can be assigned. The lvalue expression is located on the left side of an assignment statement, whereas an rvalue is located on the right side of an assignment statement. Each assignment statement must have an lvalue and an rvalue. The lvalue expression must reference a storable variable in memory. It cannot be a constant. For instance, the following lines show a few examples of lvalues:

57 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 58: General technical interview questions

int x;int* p_int;x = 1;*p_int = 5;

The variable x is an integer, which is a storable location in memory. Therefore, the statement x = 1 qualifies xto be an lvalue. Notice the second assignment statement, *p_int = 5. By using the * modifier to reference the area of memory that p_int points to, *p_int is qualified as an lvalue. In contrast, here are a few examples of what would not be considered lvalues:

#define CONST_VAL 10int x;/* example 1 */1 = x;/* example 2 */CONST_VAL = 5;

In both statements, the left side of the statement evaluates to a constant value that cannot be changed because constants do not represent storable locations in memory. Therefore, these two assignment statements do not contain lvalues and will be flagged by your compiler as errors.

10. Can an array be an lvalue?

Is an array an expression to which we can assign a value? The answer to this question is no, because an array is composed of several separate array elements that cannot be treated as a whole for assignment purposes. The following statement is therefore illegal:

int x[5], y[5];

x = y;

You could, however, use a for loop to iterate through each element of the array and assign values individually, such as in this example:

int i;int x[5];int y[5];...for (i=0; i<5; i++) x[i] = y[i]...

Additionally, you might want to copy the whole array all at once. You can do so using a library function such as the memcpy() function, which is shown here:

memcpy(x, y, sizeof(y));

58 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 59: General technical interview questions

It should be noted here that unlike arrays, structures can be treated as lvalues. Thus, you can assign one structure variable to another structure variable of the same type, such as this:

typedef struct t_name{ char last_name[25]; char first_name[15]; char middle_init[2];} NAME;...NAME my_name, your_name;...your_name = my_name;...

In the preceding example, the entire contents of the my_name structure were copied into the your_namestructure. This is essentially the same as the following line:

memcpy(your_name, my_name, sizeof(your_name));

11. What is an rvalue?

rvalue can be defined as an expression that can be assigned to an lvalue. The rvalue appears on the right side of an assignment statement.

Unlike an lvalue, an rvalue can be a constant or an expression, as shown here:

int x, y;x = 1; /* 1 is an rvalue; x is an lvalue */y = (x + 1); /* (x + 1) is an rvalue; y is an lvalue */

An assignment statement must have both an lvalue and an rvalue. Therefore, the following statement would not compile because it is missing an rvalue:

int x; x = void_function_call() /* the function void_function_call() returns nothing */

If the function had returned an integer, it would be considered an rvalue because it evaluates into something that the lvalue, x, can store.

12. Is left-to-right or right-to-left order guaranteed for operator precedence?

The simple answer to this question is neither. The C language does not always evaluate left-to-right or right-to-left. Generally, function calls are evaluated first, followed by complex expressions and then simple expressions.

Additionally, most of today's popular C compilers often rearrange the order in which the expression is evaluated in order to get better optimized code. You therefore should always implicitly define your operator precedence by using parentheses.

59 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 60: General technical interview questions

For example, consider the following expression:

a = b + c/d / function_call() * 5

The way this expression is to be evaluated is totally ambiguous, and you probably will not get the results you want. Instead, try writing it by using implicit operator precedence:

a = b + (((c/d) / function_call()) * 5)

Using this method, you can be assured that your expression will be evaluated properly and that the compiler will not rearrange operators for optimization purposes.

13. What is the difference between ++var and var++?

The ++ operator is called the increment operator. When the operator is placed before the variable (++var), the variable is incremented by 1 before it is used in the expression. When the operator is placed after the variable (var++), the expression is evaluated, and then the variable is incremented by 1.

The same holds true for the decrement operator (--). When the operator is placed before the variable, you are said to have a prefix operation. When the operator is placed after the variable, you are said to have a postfix operation.

For instance, consider the following example of postfix incrementation:

int x, y;x = 1;y = (x++ * 5);

In this example, postfix incrementation is used, and x is not incremented until after the evaluation of the expression is done. Therefore, y evaluates to 1 times 5, or 5. After the evaluation, x is incremented to 2.

Now look at an example using prefix incrementation:

int x, y;x = 1;y = (++x * 5);

This example is the same as the first one, except that this example uses prefix incrementation rather than postfix. Therefore, x is incremented before the expression is evaluated, making it 2. Hence, y evaluates to 2 times 5, or 10.

14. What does the modulus operator do?

The modulus operator (%) gives the remainder of two divided numbers. For instance, consider the following portion of code:

60 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 61: General technical interview questions

x = 15/7

If x were an integer, the resulting value of x would be 2. However, consider what would happen if you were to apply the modulus operator to the same equation:

x = 15%7

The result of this expression would be the remainder of 15 divided by 7, or 1. This is to say that 15 divided by 7 is 2 with a remainder of 1.

The modulus operator is commonly used to determine whether one number is evenly divisible into another. For instance, if you wanted to print every third letter of the alphabet, you would use the following code:

int x;for (x=1; x<=26; x++) if ((x%3) == 0) printf("%c", x+64);

The preceding example would output the string "cfilorux", which represents every third letter in the alphabet.

SQL Server General Questions

1. What is RDBMS?

Relational Data Base Management Systems (RDBMS) are database management systems that maintain data records and indices in tables. Relationships may be created and maintained across and among the data and tables. In a relational database, relationships between data items are expressed by means of tables. Interdependencies among these tables are expressed by data values rather than by pointers. This allows a high degree of data independence. An RDBMS has the capability to recombine the data items from different files, providing powerful tools for data usage.

2. What are the properties of the Relational tables?

Relational tables have six properties:

1. Values are atomic.2. Column values are of the same kind.3. Each row is unique.4. The sequence of columns is insignificant.5. The sequence of rows is insignificant.6. Each column must have a unique name.

3. What is Normalization?

Database normalization is a data design and organization process applied to data structures based on rules that help building relational databases. In relational database design, the process of organizing data to minimize redundancy is called normalization. Normalization usually involves dividing a database into two or more tables and defining relationships between the tables. The

61 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 62: General technical interview questions

objective is to isolate data so that additions, deletions, and modifications of a field can be made in just one table and then propagated through the rest of the database via the defined relationships.

4. What is De-normalization?

De-normalization is the process of attempting to optimize the performance of a database by adding redundant data. It is sometimes necessary because current DBMSs implement the relational model poorly. A true relational DBMS would allow for a fully normalized database at the logical level, while providing physical storage of data that is tuned for high performance. De-normalization is a technique to move from higher to lower normal forms of database modeling in order to speed up database access.

5. What are different normalization forms?

1. 1NF: Eliminate Repeating Groups Make a separate table for each set of related attributes, and give each table a primary key. Each field contains at most one value from its attribute domain.

2. 2NF: Eliminate Redundant Data If an attribute depends on only part of a multi-valued key, remove it to a separate table.

3. 3NF: Eliminate Columns Not Dependent On Key If attributes do not contribute to a description of the key, remove them to a separate table. All attributes must be directly dependent on the primary key.

4. BCNF: Boyce-Codd Normal Form If there are non-trivial dependencies between candidate key attributes, separate them out into distinct tables.

5. 4NF: Isolate Independent Multiple Relationships No table may contain two or more 1:n or n:m relationships that are not directly related.

6. 5NF: Isolate Semantically Related Multiple Relationships There may be practical constrains on information that justify separating logically related many-to-many relationships.

7. ONF: Optimal Normal Form A model limited to only simple (elemental) facts, as expressed in Object Role Model notation.

8. DKNF: Domain-Key Normal Form A model free from all modification anomalies is said to be in DKNF.

Remember, these normalization guidelines are cumulative. For a database to be in 3NF, it must first fulfill all the criteria of a 2NF and 1NF database.

6. What is Stored Procedure?

A stored procedure is a named group of SQL statements that have been previously created and stored in the server database. Stored procedures accept input parameters so that a single procedure can be used over the network by several clients using different input data. And when the procedure is modified, all clients automatically get the new version. Stored procedures reduce network traffic and improve performance. Stored procedures can be used to help ensure the integrity of the database.

e.g. sp_helpdb, sp_renamedb, sp_depends etc.

7. What is Trigger?

A trigger is a SQL procedure that initiates an action when an event (INSERT, DELETE or UPDATE) occurs. Triggers are stored in and managed by the DBMS. Triggers are used to maintain the

62 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 63: General technical interview questions

referential integrity of data by changing the data in a systematic fashion. A trigger cannot be called or executed; DBMS automatically fires the trigger as a result of a data modification to the associated table. Triggers can be viewed as similar to stored procedures in that both consist of procedural logic that is stored at the database level. Stored procedures, however, are not event-drive and are not attached to a specific table as triggers are. Stored procedures are explicitly executed by invoking a CALL to the procedure while triggers are implicitly executed. In addition, triggers can also execute stored procedures.

8. What is Nested Trigger?

A trigger can also contain INSERT, UPDATE and DELETE logic within itself, so when the trigger is fired because of data modification it can also cause another data modification, thereby firing another trigger. A trigger that contains data modification logic within itself is called a nested trigger.

9. What is View?

A simple view can be thought of as a subset of a table. It can be used for retrieving data, as well as updating or deleting rows. Rows updated or deleted in the view are updated or deleted in the table the view was created with. It should also be noted that as data in the original table changes, so does data in the view, as views are the way to look at part of the original table. The results of using a view are not permanently stored in the database. The data accessed through a view is actually constructed using standard T-SQL select command and can come from one to many different base tables or even other views.

10. What is Index?

An index is a physical structure containing pointers to the data. Indices are created in an existing table to locate rows more quickly and efficiently. It is possible to create an index on one or more columns of a table, and each index is given a name. The users cannot see the indexes; they are just used to speed up queries. Effective indexes are one of the best ways to improve performance in a database application. A table scan happens when there is no index available to help a query. In a table scan SQL Server examines every row in the table to satisfy the query results. Table scans are sometimes unavoidable, but on large tables, scans have a terrific impact on performance.

11. What is a Linked Server?

Linked Servers is a concept in SQL Server by which we can add other SQL Server to a Group and query both the SQL Server dbs using T-SQL Statements. With a linked server, you can create very clean, easy to follow, SQL statements that allow remote data to be retrieved, joined and combined with local data. Stored Procedure sp_addlinkedserver, sp_addlinkedsrvlogin will be used add new Linked Server.

12. What is Cursor?

Cursor is a database object used by applications to manipulate data in a set on a row-by- row basis, instead of the typical SQL commands that operate on all the rows in the set at one time. 

In order to work with a cursor we need to perform some steps in the following order:

1. Declare cursor2. Open cursor

63 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 64: General technical interview questions

3. Fetch row from the cursor4. Process fetched row5. Close cursor6. Deallocate cursor

13. What is Collation?

Collation refers to a set of rules that determine how data is sorted and compared. Character data is sorted using rules that define the correct character sequence, with options for specifying case sensitivity, accent marks, kana character types and character width.

14. What is Difference between Function and Stored Procedure?

UDF can be used in the SQL statements anywhere in the WHERE/HAVING/SELECT section where as Stored procedures cannot be. UDFs that return tables can be treated as another rowset. This can be used in JOINs with other tables. Inline UDF's can be thought of as views that take parameters and can be used in JOINs and other Rowset operations.

15. What is sub-query? Explain properties of sub-query?

Sub-queries are often referred to as sub-selects, as they allow a SELECT statement to be executed arbitrarily within the body of another SQL statement. A sub-query is executed by enclosing it in a set of parentheses. Sub-queries are generally used to return a single row as an atomic value, though they may be used to compare values against multiple rows with the IN keyword.

A subquery is a SELECT statement that is nested within another T-SQL statement. A subquery SELECT statement if executed independently of the T-SQL statement, in which it is nested, will return a resultset. Meaning a subquery SELECT statement can standalone and is not depended on the statement in which it is nested. A subquery SELECT statement can return any number of values, and can be found in, the column list of a SELECT statement, a FROM, GROUP BY, HAVING, and/or ORDER BY clauses of a T-SQL statement. A Subquery can also be used as a parameter to a function call. Basically a subquery can be used anywhere an expression can be used.

16. What are different Types of Join?

1. Cross Join A cross join that does not have a WHERE clause produces the Cartesian product of the tables involved in the join. The size of a Cartesian product result set is the number of rows in the first table multiplied by the number of rows in the second table. The common example is when company wants to combine each product with a pricing table to analyze each product at each price.

2. Inner Join A join that displays only the rows that have a match in both joined tables is known as inner Join. This is the default type of join in the Query and View Designer.

3. Outer Join A join that includes rows even if they do not have related rows in the joined table is an Outer Join. You can create three different outer join to specify the unmatched rows to be included:

1. Left Outer Join: In Left Outer Join all rows in the first-named table i.e. "left" table, which appears leftmost in the JOIN clause are included. Unmatched rows in the right table do not appear.

2. Right Outer Join: In Right Outer Join all rows in the second-named table i.e. "right" table, which appears rightmost in the JOIN clause are included. Unmatched rows in the left table are not included.

64 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 65: General technical interview questions

3. Full Outer Join: In Full Outer Join all rows in all joined tables are included, whether they are matched or not.

4. Self Join This is a particular case when one table joins to itself, with one or two aliases to avoid confusion. A self join can be of any type, as long as the joined tables are the same. A self join is rather unique in that it involves a relationship with only one table. The common example is when company has a hierarchal reporting structure whereby one member of staff reports to another. Self Join can be Outer Join or Inner Join.

17. What are primary keys and foreign keys?

Primary keys are the unique identifiers for each row. They must contain unique values and cannot be null. Due to their importance in relational databases, Primary keys are the most fundamental of all keys and constraints. A table can have only one Primary key. Foreign keys are both a method of ensuring data integrity and a manifestation of the relationship between tables.

18. What is User Defined Functions? What kind of User-Defined Functions can be created?

User-Defined Functions allow defining its own T-SQL functions that can accept 0 or more parameters and return a single scalar data value or a table data type.Different Kinds of User-Defined Functions created are:

1. Scalar User-Defined Function A Scalar user-defined function returns one of the scalar data types. Text, ntext, image and timestamp data types are not supported. These are the type of user-defined functions that most developers are used to in other programming languages. You pass in 0 to many parameters and you get a return value.

2. Inline Table-Value User-Defined Function An Inline Table-Value user-defined function returns a table data type and is an exceptional alternative to a view as the user-defined function can pass parameters into a T-SQL select command and in essence provide us with a parameterized, non-updateable view of the underlying tables.

3. Multi-statement Table-Value User-Defined Function A Multi-Statement Table-Value user-defined function returns a table and is also an exceptional alternative to a view as the function can support multiple T-SQL statements to build the final result where the view is limited to a single SELECT statement. Also, the ability to pass parameters into a TSQL select command or a group of them gives us the capability to in essence create a parameterized, non-updateable view of the data in the underlying tables. Within the create function command you must define the table structure that is being returned. After creating this type of user-defined function, It can be used in the FROM clause of a T-SQL command unlike the behavior found when using a stored procedure which can also return record sets.

19. What is Identity?

Identity (or AutoNumber) is a column that automatically generates numeric values. A start and increment value can be set, but most DBA leave these at 1. A GUID column also generates numbers; the value of this cannot be controlled. Identity/GUID columns do not need to be indexed.

20. What is DataWarehousing?

1. Subject-oriented, meaning that the data in the database is organized so that all the data elements relating to the same real-world event or object are linked together;

65 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 66: General technical interview questions

2. Time-variant, meaning that the changes to the data in the database are tracked and recorded so that reports can be produced showing changes over time;

3. Non-volatile, meaning that data in the database is never over-written or deleted, once committed, the data is static, read-only, but retained for future reporting.

4. Integrated, meaning that the database contains data from most or all of an organization's operational applications, and that this data is made consistent.

SQL Server Common Questions

1. Which TCP/IP port does SQL Server run on? How can it be changed?

SQL Server runs on port 1433. It can be changed from the Network Utility TCP/IP properties.

2. What are the difference between clustered and a non-clustered index?

1. A clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages.

2. A non clustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a non clustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.

3. What are the different index configurations a table can have?

A table can have one of the following index configurations:

1. No indexes2. A clustered index3. A clustered index and many nonclustered indexes4. A nonclustered index5. Many nonclustered indexes

4. What are different types of Collation Sensitivity?

1. Case sensitivity - A and a, B and b, etc.2. Accent sensitivity3. Kana Sensitivity - When Japanese kana characters Hiragana and Katakana are treated

differently, it is called Kana sensitive.4. Width sensitivity - A single-byte character (half-width) and the same character

represented as a double-byte character (full-width) are treated differently than it is width sensitive.

5. What is OLTP (Online Transaction Processing)?

In OLTP - online transaction processing systems relational database design use the discipline of data modeling and generally follow the Codd rules of data normalization in order to ensure absolute data integrity. Using these rules complex information is broken down into its most simple structures (a table) where all of the individual atomic level elements relate to each other and satisfy the normalization rules.

6. What's the difference between a primary key and a unique key?

66 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 67: General technical interview questions

Both primary key and unique key enforces uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn't allow NULLs, but unique key allows one NULL only.

7. What is difference between DELETE and TRUNCATE commands?

Delete command removes the rows from a table based on the condition that we provide with a WHERE clause. Truncate will actually remove all the rows from a table and there will be no data in the table after we run the truncate command.

1. TRUNCATE:1. TRUNCATE is faster and uses fewer system and transaction log resources than

DELETE.2. TRUNCATE removes the data by deallocating the data pages used to store the

table's data, and only the page deallocations are recorded in the transaction log.3. TRUNCATE removes all rows from a table, but the table structure, its columns,

constraints, indexes and so on, remains. The counter used by an identity for new rows is reset to the seed for the column.

4. You cannot use TRUNCATE TABLE on a table referenced by a FOREIGN KEY constraint. Because TRUNCATE TABLE is not logged, it cannot activate a trigger.

5. TRUNCATE cannot be rolled back.6. TRUNCATE is DDL Command.7. TRUNCATE Resets identity of the table

2. DELETE:1. DELETE removes rows one at a time and records an entry in the transaction log for

each deleted row.2. If you want to retain the identity counter, use DELETE instead. If you want to

remove table definition and its data, use the DROP TABLE statement.3. DELETE Can be used with or without a WHERE clause4. DELETE Activates Triggers.5. DELETE can be rolled back.6. DELETE is DML Command.7. DELETE does not reset identity of the table.

Note: DELETE and TRUNCATE both can be rolled back when surrounded by TRANSACTION if the current session is not closed. If TRUNCATE is written in Query Editor surrounded by TRANSACTION and if session is closed, it can not be rolled back but DELETE can be rolled back.

8. When is the use of UPDATE_STATISTICS command?

This command is basically used when a large processing of data has occurred. If a large amount of deletions any modification or Bulk Copy into the tables has occurred, it has to update the indexes to take these changes into account. UPDATE_STATISTICS updates the indexes on these tables accordingly.

9. What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?

They specify a search condition for a group or an aggregate. But the difference is that HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP BY is not used, HAVING behaves like a WHERE clause. Having Clause is basically used only

67 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 68: General technical interview questions

with the GROUP BY function in a query whereas WHERE Clause is applied to each row before they are part of the GROUP BY function in a query.

10. What are the properties and different Types of Sub-Queries?

1. Properties of Sub-Query1. A sub-query must be enclosed in the parenthesis.2. A sub-query must be put in the right hand of the comparison operator, and3. A sub-query cannot contain an ORDER-BY clause.4. A query can contain more than one sub-query.

2. Types of Sub-Query1. Single-row sub-query, where the sub-query returns only one row.2. Multiple-row sub-query, where the sub-query returns multiple rows,. and3. Multiple column sub-query, where the sub-query returns multiple columns

11. What is SQL Profiler?

SQL Profiler is a graphical tool that allows system administrators to monitor events in an instance of Microsoft SQL Server. You can capture and save data about each event to a file or SQL Server table to analyze later. For example, you can monitor a production environment to see which stored procedures are hampering performances by executing too slowly.

Use SQL Profiler to monitor only the events in which you are interested. If traces are becoming too large, you can filter them based on the information you want, so that only a subset of the event data is collected. Monitoring too many events adds overhead to the server and the monitoring process and can cause the trace file or trace table to grow very large, especially when the monitoring process takes place over a long period of time.

12. What are the authentication modes in SQL Server? How can it be changed?

Windows mode and Mixed Mode - SQL and Windows. To change authentication mode in SQL Server click Start, Programs, Microsoft SQL Server and click SQL Enterprise Manager to run SQL Enterprise Manager from the Microsoft SQL Server program group. Select the server then from the Tools menu select SQL Server Configuration Properties, and choose the Security page.

13. Which command using Query Analyzer will give you the version of SQL server and operating system?

SELECT SERVERPROPERTY ('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition').

14. What is SQL Server Agent?

SQL Server agent plays an important role in the day-to-day tasks of a database administrator (DBA). It is often overlooked as one of the main tools for SQL Server management. Its purpose is to ease the implementation of tasks for the DBA, with its full- function scheduling engine, which allows you to schedule your own jobs and scripts.

15. Can a stored procedure call itself or recursive stored procedure? How much level SP nesting is possible?

68 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 69: General technical interview questions

Yes. Because Transact-SQL supports recursion, you can write stored procedures that call themselves. Recursion can be defined as a method of problem solving wherein the solution is arrived at by repetitively applying it to subsets of the problem. A common application of recursive logic is to perform numeric computations that lend themselves to repetitive evaluation by the same processing steps. Stored procedures are nested when one stored procedure calls another or executes managed code by referencing a CLR routine, type, or aggregate. You can nest stored procedures and managed code references up to 32 levels.

16. What is Log Shipping?

Log shipping is the process of automating the backup of database and transaction log files on a production SQL server, and then restoring them onto a standby server. Enterprise Editions only supports log shipping. In log shipping the transactional log file from one server is automatically updated into the backup database on the other server. If one server fails, the other server will have the same db and can be used this as the Disaster Recovery plan. The key feature of log shipping is that it will automatically backup transaction logs throughout the day and automatically restore them on the standby server at defined interval.

17. Name 3 ways to get an accurate count of the number of records in a table?

SELECT * FROM table1 SELECT COUNT(*) FROM table1 SELECT rows FROM sysindexes WHERE id = OBJECT_ID(table1) AND indid < 2

18. What does it mean to have QUOTED_IDENTIFIER ON? What are the implications of having it OFF?

When SET QUOTED_IDENTIFIER is ON, identifiers can be delimited by double quotation marks, and literals must be delimited by single quotation marks. When SET QUOTED_IDENTIFIER is OFF, identifiers cannot be quoted and must follow all Transact-SQL rules for identifiers.

19. What is the difference between a Local and a Global temporary table?

1. A local temporary table exists only for the duration of a connection or, if defined inside a compound statement, for the duration of the compound statement.

2. A global temporary table remains in the database permanently, but the rows exist only within a given connection. When connection is closed, the data in the global temporary table disappears. However, the table definition remains with the database for access when database is opened next time.

20. What is the STUFF function and how does it differ from the REPLACE function?

STUFF function is used to overwrite existing characters. Using this syntax, STUFF (string_expression, start, length, replacement_characters), string_expression is the string that will have characters substituted, start is the starting position, length is the number of characters in the string that are substituted, and replacement_characters are the new characters interjected into the string. REPLACE function to replace existing characters of all occurrences. Using the syntax REPLACE (string_expression, search_string, replacement_string), where every incidence of search_string found in the string_expression will be replaced with replacement_string.

21. What is PRIMARY KEY?

69 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 70: General technical interview questions

A PRIMARY KEY constraint is a unique identifier for a row within a database table. Every table should have a primary key constraint to uniquely identify each row and only one primary key constraint can be created for each table. The primary key constraints are used to enforce entity integrity.

22. What is UNIQUE KEY constraint?

A UNIQUE constraint enforces the uniqueness of the values in a set of columns, so no duplicate values are entered. The unique key constraints are used to enforce entity integrity as the primary key constraints.

23. What is FOREIGN KEY?

A FOREIGN KEY constraint prevents any actions that would destroy links between tables with the corresponding data values. A foreign key in one table points to a primary key in another table. Foreign keys prevent actions that would leave rows with foreign key values when there are no primary keys with that value. The foreign key constraints are used to enforce referential integrity.

24. What is CHECK Constraint?

A CHECK constraint is used to limit the values that can be placed in a column. The check constraints are used to enforce domain integrity.

25. What is NOT NULL Constraint?

A NOT NULL constraint enforces that the column will not accept null values. The not null constraints are used to enforce domain integrity, as the check constraints.

26. How to get @@ERROR and @@ROWCOUNT at the same time?

If @@Rowcount is checked after Error checking statement then it will have 0 as the value of @@Recordcount as it would have been reset. And if @@Recordcount is checked before the error-checking statement then @@Error would get reset. To get @@error and @@rowcount at the same time do both in same statement and store them in local variable.

SELECT @RC = @@ROWCOUNT, @ER = @@ERROR

27. What is a Scheduled Jobs or What is a Scheduled Tasks?

Scheduled tasks let user automate processes that run on regular or predictable cycles. User can schedule administrative tasks, such as cube processing, to run during times of slow business activity. User can also determine the order in which tasks run by creating job steps within a SQL Server Agent job. E.g. back up database, Update Stats of Tables. Job steps give user control over flow of execution. If one job fails, user can configure SQL Server Agent to continue to run the remaining tasks or to stop execution.

28. What are the advantages of using Stored Procedures?

1. Stored procedure can reduced network traffic and latency, boosting application performance.

70 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 71: General technical interview questions

2. Stored procedure execution plans can be reused, staying cached in SQL Server's memory, reducing server overhead.

3. Stored procedures help promote code reuse.4. Stored procedures can encapsulate logic. You can change stored procedure code without

affecting clients.5. Stored procedures provide better security to your data.

29. What is a table called, if it has neither Cluster nor Non-cluster Index? What is it used for?

Unindexed table or Heap. Microsoft Press Books and Book on Line (BOL) refers it as Heap. A heap is a table that does not have a clustered index and, therefore, the pages are not linked by pointers. The IAM pages are the only structures that link the pages in a table together. Unindexed tables are good for fast storing of data. Many times it is better to drop all indexes from table and then do bulk of inserts and to restore those indexes after that.

30. Can SQL Servers linked to other servers like Oracle?

SQL Server can be linked to any server provided it has OLE-DB provider from Microsoft to allow a link. E.g. Oracle has an OLE-DB provider for oracle that Microsoft provides to add it as linked server to SQL Server group.

31. What is BCP? When does it used?

BulkCopy is a tool used to copy huge amount of data from tables and views. BCP does not copy the structures same as source to destination. BULK INSERT command helps to import a data file into a database table or view in a user-specified format.

32. How to implement one-to-one, one-to-many and many-to-many relationships while designing tables?

One-to-One relationship can be implemented as a single table and rarely as two tables with primary and foreign key relationships. One-to-Many relationships are implemented by splitting the data into two tables with primary key and foreign key relationships. Many-to-Many relationships are implemented using a junction table with the keys from both the tables forming the composite primary key of the junction table.

33. What is an execution plan? When would you use it? How would you view the execution plan?

An execution plan is basically a road map that graphically or textually shows the data retrieval methods chosen by the SQL Server query optimizer for a stored procedure or ad- hoc query and is a very useful tool for a developer to understand the performance characteristics of a query or stored procedure since the plan is the one that SQL Server will place in its cache and use to execute the stored procedure or query. From within Query Analyzer is an option called "Show Execution Plan" (located on the Query drop-down menu). If this option is turned on it will display query execution plan in separate window when query is ran again.

71 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 72: General technical interview questions

SQL Server 2008

1. What are the basic functions for master, msdb, model, tempdb and resource databases?

1. The master database holds information for all databases located on the SQL Server instance and is theglue that holds the engine together. Because SQL Server cannot start without a functioning masterdatabase, you must administer this database with care.

2. The msdb database stores information regarding database backups, SQL Agent information, DTS packages, SQL Server jobs, and some replication information such as for log shipping.

3. The tempdb holds temporary objects such as global and local temporary tables and stored procedures.

4. The model is essentially a template database used in the creation of any new user database created in the instance.

5. The resoure Database is a read-only database that contains all the system objects that are included with SQL Server. SQL Server system objects, such as sys.objects, are physically persisted in the Resource database, but they logically appear in the sys schema of every database. The Resource database does not contain user data or user metadata.

2. What is Service Broker?

Service Broker is a message-queuing technology in SQL Server that allows developers to integrate SQL Server fully into distributed applications. Service Broker is feature which provides facility to SQL Server to send an asynchronous, transactional message. it allows a database to send a message to another database without waiting for the response, so the application will continue to function if the remote database is temporarily unavailable.

3. Where SQL server user names and passwords are stored in SQL server?

They get stored in System Catalog Views sys.server_principals and sys.sql_logins.

4. What is Policy Management?

Policy Management in SQL SERVER 2008 allows you to define and enforce policies for configuring and managing SQL Server across the enterprise. Policy-Based Management is configured in SQL Server Management Studio (SSMS). Navigate to the Object Explorer and expand the Management node and the Policy Management node; you will see the Policies, Conditions, and Facets nodes.

5. What is Replication and Database Mirroring?

Database mirroring can be used with replication to provide availability for the publication database. Database mirroring involves two copies of a single database that typically reside on different

72 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 73: General technical interview questions

computers. At any given time, only one copy of the database is currently available to clients which are known as the principal database. Updates made by clients to the principal database are applied on the other copy of the database, known as the mirror database. Mirroring involves applying the transaction log from every insertion, update, or deletion made on the principal database onto the mirror database.

6. What are Sparse Columns?

A sparse column is another tool used to reduce the amount of physical storage used in a database. They are the ordinary columns that have an optimized storage for null values. Sparse columns reduce the space requirements for null values at the cost of more overhead to retrieve nonnull values.

7. What does TOP Operator Do?

The TOP operator is used to specify the number of rows to be returned by a query. The TOP operator has new addition in SQL SERVER 2008 that it accepts variables as well as literal values and can be used with INSERT, UPDATE, and DELETES statements.

8. What is CTE?

CTE is an abbreviation Common Table Expression. A Common Table Expression (CTE) is an expression that can be thought of as a temporary result set which is defined within the execution of a single SQL statement. A CTE is similar to a derived table in that it is not stored as an object and lasts only for the duration of the query.

9. What is MERGE Statement?

MERGE is a new feature that provides an efficient way to perform multiple DML operations. In previous versions of SQL Server, we had to write separate statements to INSERT, UPDATE, or DELETE data based on certain conditions, but now, using MERGE statement we can include the logic of such data modifications in one statement that even checks when the data is matched then just update it and when unmatched then insert it. One of the most important advantages of MERGE statement is all the data is read and processed only once.

10. What is Filtered Index?

Filtered Index is used to index a portion of rows in a table that means it applies filter on INDEX which improves query performance, reduce index maintenance costs, and reduce index storage costs compared with full-table indexes. When we see an Index created with some where clause then that is actually a FILTERED INDEX.

11. Which are new data types introduced in SQL SERVER 2008?

1. The GEOMETRY Type: The GEOMETRY data type is a system .NET common language runtime (CLR) data type in SQL Server. This type represents data in a two-dimensional Euclidean coordinate system.

2. The GEOGRAPHY Type: The GEOGRAPHY datatype’s functions are the same as with GEOMETRY. The difference between the two is that when you specify GEOGRAPHY, you are usually specifying points in terms of latitude and longitude.

3. New Date and Time Datatypes: SQL Server 2008 introduces four new datatypes related to date and time: DATE, TIME, DATETIMEOFFSET, and DATETIME2.

73 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 74: General technical interview questions

1. DATE: The new DATE type just stores the date itself. It is based on the Gregorian calendar and handles years from 1 to 9999.

2. TIME: The new TIME (n) type stores time with a range of 00:00:00.0000000 through 23:59:59.9999999. The precision is allowed with this type. TIME supports seconds down to 100 nanoseconds. The n in TIME (n) defines this level of fractional second precision, from 0 to 7 digits of precision.

3. The DATETIMEOFFSET Type: DATETIMEOFFSET (n) is the time-zone-aware version of a datetime datatype. The name will appear less odd when you consider what it really is: a date + a time + a time-zone offset. The offset is based on how far behind or ahead you are from Coordinated Universal Time (UTC) time.

4. The DATETIME2 Type: It is an extension of the datetime type in earlier versions of SQL Server. This new datatype has a date range covering dates from January 1 of year 1 through December 31 of year 9999. This is a definite improvement over the 1753 lower boundary of the datetime datatype. DATETIME2 not only includes the larger date range, but also has a timestamp and the same fractional precision that TIME type provides

12. What are the Advantages of using CTE?

1. Using CTE improves the readability and makes maintenance of complex queries easy.2. The query can be divided into separate, simple, logical building blocks which can be then

used to build more complex CTEs until final result set is generated.3. CTE can be defined in functions, stored procedures, triggers or even views.4. After a CTE is defined, it can be used as a Table or a View and can SELECT, INSERT,

UPDATE or DELETE Data.

13. What is CLR?

In SQL Server 2008, SQL Server objects such as user-defined functions can be created using such CLR languages. This CLR language support extends not only to user-defined functions, but also to stored procedures and triggers. You can develop such CLR add-ons to SQL Server using Visual Studio 2008.

14. What are synonyms?

Synonyms give you the ability to provide alternate names for database objects. You can alias object names; for example, using the Employee table as Emp. You can also shorten names. This is especially useful when dealing with three and four part names; for example, shortening server.database.owner.object to object.

15. What is LINQ?

Language Integrated Query (LINQ) adds the ability to query objects using .NET languages. The LINQ to SQL object/relational mapping (O/RM) framework provides the following basic features:

1. Tools to create classes (usually called entities) mapped to database tables2. Compatibility with LINQ's standard query operations3. The DataContext class, with features such as entity record monitoring, automatic SQL

statement generation, record concurrency detection, and much more

16. What is Isolation Levels?

74 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 75: General technical interview questions

Transactions specify an isolation level that defines the degree to which one transaction must be isolated from resource or data modifications made by other transactions. Isolation levels are described in terms of which concurrency side-effects, such as dirty reads or phantom reads, are allowed.

Transaction isolation levels control:

1. Whether locks are taken when data is read, and what type of locks are requested.2. How long the read locks are held.3. Whether a read operation referencing rows modified by another transaction:

1. Blocks until the exclusive lock on the row is freed.2. Retrieves the committed version of the row that existed at the time the statement

or transaction started.3. Reads the uncommitted data modification.

17. What is use of EXCEPT Clause?

EXCEPT clause is similar to MINUS operation in Oracle. The EXCEPT query and MINUS query returns all rows in the first query that are not returned in the second query. Each SQL statement within the EXCEPT query and MINUS query must have the same number of fields in the result sets with similar data types.

18. How would you handle error in SQL SERVER 2008?

SQL Server now supports the use of TRY...CATCH con handling. TRY...CATCH lets us build error handling at the level we need, in the way w to, by setting a region where if any error occurs, it will break out of the region and head to an error handler. 

The basic structure is as follows:BEGIN TRY stmts.. END TRYBEGIN CATCHstmts..END CATCH

19. What is RAISEERROR?

RaiseError generates an error message and initiates error processing for the session. RAISERROR can either reference a user-defined message stored in the sys.messages catalog view or build a message dynamically. The message is returned as a server error message to the calling application or to an associated CATCH block of a TRY | CATCH construct.

20. How to rebuild Master Database?

Master database is system database and it contains information about running server's configuration. When SQL Server 2005 is installed it usually creates master, model, msdb, tempdb resource and distribution system database by default. Only Master database is th one which is absolutely must have database. Without Master database SQL Server cannot be started. This is the reason it is extremely important to backup Master database.

75 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 76: General technical interview questions

To rebuild the Master database, Run Setup.exe, verify, and repair a SQL Server instance, and rebuild the system databases. This procedure is most often used to rebuild the master database for a corrupted installation of SQL Server.

21. What is XML Datatype?

The xml data type lets you store XML documents and fragments in a SQL Server database. An XML fragment is an XML instance that is missing a single top-level element. You can create columns and variables of the xml type and store XML instances in them. The xml data type and associated methods help integrate XML into the relational framework of S Server.

22. What is Data Compression?

In SQL SERVE 2008 Data Compression comes in two flavors:

1. Row Compression: Row compression changes the format of physical storage of data. It minimize the metadata (column information, length, offsets etc) associated with each record. Numeric data types and fixed length strings are stored in variable-length storage format, just like Varchar.

2. Page Compression: Page compression allows common data to be shared between rows for a given page. Its uses the following techniques to compress data:

1. Row compression.2. Prefix Compression. For every column in a page duplicate prefixes are identified.

These prefixes are saved in compression information headers (CI) which resides after page header. A reference number is assigned to these prefixes and that reference number is replaced where ever those prefixes are being used.

3. Dictionary Compression: Dictionary compression searches for duplicate values throughout the page and stores them in CI. The main difference between prefix and dictionary compression is that prefix is only restricted to one column while dictionary is applicable to the complete page.

23. What is Catalog Views?

Catalog views return information that is used by the SQL Server Database Engine. Catalog Views are the most general interface to the catalog metadata and provide the most efficient way to obtain, transform, and present customized forms of this information. All user- available catalog metadata is exposed through catalog views.

24. What is PIVOT and UNPIVOT?

A Pivot Table can automatically sort, count, and total the data stored in one table or spreadsheet and create a second table displaying the summarized data. The PIVOT operator turns the values of a specified column into column names, effectively rotating a table.

UNPIVOT table is reverse of PIVOT Table.

25. What is Dirty Read ?

A dirty read occurs when two operations say, read and write occurs together giving the incorrect or unedited data. Suppose, A has changed a row, but has not committed the changes. B reads the uncommitted data but his view of the data may be wrong so that is Dirty Read.

76 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 77: General technical interview questions

26. What is Aggregate Functions?

Aggregate functions perform a calculation on a set of values and return a single value. Aggregate functions ignore NULL values except COUNT function. HAVING clause is used, along with GROUP BY, for filtering query using aggregate values.

Following functions are aggregate functions. 

AVG, MIN CHECKSUM_AGG, SUM, COUNT, STDEV, COUNT_BIG, STDEVP, GROUPING, VAR, MAX. VARP

27. What do you mean by Table Sample?

TABLESAMPLE allows you to extract a sampling of rows from a table in the FROM clause. The rows retrieved are random and they are not in any order. This sampling can be based on a percentage of number of rows. You can use TABLESAMPLE when only a sampling of rows is necessary for the application instead of a full result set.

28. What is the difference between UNION and UNION ALL?

1. UNION The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type. With UNION, only distinct values are selected.

2. UNION ALL The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values.

The difference between Union and Union all is that Union all will not eliminate duplicate rows, instead it just pulls all rows from all tables fitting your query specifics and combines them into a table.

29. What is B-Tree?

The database server uses a B-tree structure to organize index information. B-Tree generally has following types of index pages or nodes:

1. root node: A root node contains node pointers to branch nodes which can be only one.2. branch node: A branch node contains pointers to leaf nodes or other branch nodes which

can be two or more.3. leaf nodes: A leaf node contains index items and orizantal pointers to other leaf nodes

which can be many.

77 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 78: General technical interview questions

DBMS Basics

1. What is database?

A database is a logically coherent collection of data with some inherent meaning, representing some aspect of real world and which is designed, built and populated with data for a specific purpose.

2. What is DBMS?

It is a collection of programs that enables user to create and maintain a database. In other words it is general-purpose software that provides the users with the processes of defining, constructing and manipulating the database for various applications.

3. What is a Database system?

The database and DBMS software together is called as Database system.

4. What are the advantages of DBMS?

1. Redundancy is controlled.2. Unauthorised access is restricted.3. Providing multiple user interfaces.4. Enforcing integrity constraints.5. Providing backup and recovery.

5. What are the disadvantage in File Processing System?

1. Data redundancy and inconsistency.2. Difficult in accessing data.3. Data isolation.4. Data integrity.5. Concurrent access is not possible.6. Security Problems.

6. Describe the three levels of data abstraction?

The are three levels of abstraction:

1. Physical level: The lowest level of abstraction describes how data are stored.

78 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 79: General technical interview questions

2. Logical level: The next higher level of abstraction, describes what data are stored in database and what relationship among those data.

3. View level: The highest level of abstraction describes only part of entire database.

7. Define the "integrity rules"?

There are two Integrity rules.

1. Entity Integrity: States that "Primary key cannot have NULL value"2. Referential Integrity: States that "Foreign Key can be either a NULL value or should be

Primary Key value of other relation.

8. What is extension and intension?

1. Extension: It is the number of tuples present in a table at any instance. This is time dependent.

2. Intension: It is a constant value that gives the name, structure of table and the constraints laid on it.

9. What is System R? What are its two major subsystems?

System R was designed and developed over a period of 1974-79 at IBM San Jose Research Center. It is a prototype and its purpose was to demonstrate that it is possible to build a Relational System that can be used in a real life environment to solve real life problems, with performance at least comparable to that of existing system.Its two subsystems are

1. Research Storage2. System Relational Data System.

10. How is the data structure of System R different from the relational structure?

Unlike Relational systems in System R

1. Domains are not supported2. Enforcement of candidate key uniqueness is optional3. Enforcement of entity integrity is optional4. Referential integrity is not enforced

11. What is Data Independence?

Data independence means that "the application is independent of the storage structure and access strategy of data". In other words, The ability to modify the schema definition in one level should not affect the schema definition in the next higher level.Two types of Data Independence:

1. Physical Data Independence: Modification in physical level should not affect the logical level.

2. Logical Data Independence: Modification in logical level should affect the view level.

NOTE: Logical Data Independence is more difficult to achieve

79 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 80: General technical interview questions

12. What is a view? How it is related to data independence?

A view may be thought of as a virtual table, that is, a table that does not really exist in its own right but is instead derived from one or more underlying base table. In other words, there is no stored file that direct represents the view instead a definition of view is stored in data dictionary. 

Growth and restructuring of base tables is not reflected in views. Thus the view can insulate users from the effects of restructuring and growth in the database. Hence accounts for logical data independence.

13. What is Data Model?

A collection of conceptual tools for describing data, data relationships data semantics and constraints.

14. What is E-R model?

This data model is based on real world that consists of basic objects called entities and of relationship among these objects. Entities are described in a database by a set of attributes.

15. What is Object Oriented model?

This model is based on collection of objects. An object contains values stored in instance variables with in the object. An object also contains bodies of code that operate on the object. These bodies of code are called methods. Objects that contain same types of values and the same methods are grouped together into classes.

16. What is an Entity?

It is a 'thing' in the real world with an independent existence.

17. What is an Entity type?

It is a collection (set) of entities that have same attributes.

18. What is an Entity set?

It is a collection of all entities of particular entity type in the database.

19. What is an Extension of entity type?

The collections of entities of a particular entity type are grouped together into an entity set.

20. What is Weak Entity set?

An entity set may not have sufficient attributes to form a primary key, and its primary key compromises of its partial key and primary key of its parent entity, then it is said to be Weak Entity set.

21. What is an attribute?

80 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 81: General technical interview questions

It is a particular property, which describes the entity.

22. What is a Relation Schema and a Relation?

A relation Schema denoted by R(A1, A2, ..., An) is made up of the relation name R and the list of attributes Ai that it contains. A relation is defined as a set of tuples. Let r be the relation which contains set tuples (t1, t2, t3, ..., tn). Each tuple is an ordered list of n-values t=(v1,v2, ..., vn).

23. What is degree of a Relation?

It is the number of attribute of its relation schema.

24. What is Relationship?

It is an association among two or more entities.

25. What is Relationship set?

The collection (or set) of similar relationships.

26. What is Relationship type?

Relationship type defines a set of associations or a relationship set among a given set of entity types.

27. What is degree of Relationship type?

It is the number of entity type participating.

28. What is DDL (Data Definition Language)?

A data base schema is specifies by a set of definitions expressed by a special language called DDL.

29. What is VDL (View Definition Language)?

It specifies user views and their mappings to the conceptual schema.

30. What is SDL (Storage Definition Language)?

This language is to specify the internal schema. This language may specify the mapping between two schemas.

31. What is Data Storage - Definition Language?

The storage structures and access methods used by database system are specified by a set of definition in a special type of DDL called data storage-definition language.

32. What is DML (Data Manipulation Language)?

This language that enable user to access or manipulate data as organised by appropriate data model.

81 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 82: General technical interview questions

1. Procedural DML or Low level: DML requires a user to specify what data are needed and how to get those data.

2. Non-Procedural DML or High level: DML requires a user to specify what data are needed without specifying how to get those data.

33. What is DML Compiler?

It translates DML statements in a query language into low-level instruction that the query evaluation engine can understand.

34. What is Query evaluation engine?

It executes low-level instruction generated by compiler.

35. What is DDL Interpreter?

It interprets DDL statements and record them in tables containing metadata.

36. What is Record-at-a-time?

The Low level or Procedural DML can specify and retrieve each record from a set of records. This retrieve of a record is said to be Record-at-a-time.

37. What is Set-at-a-time or Set-oriented?

The High level or Non-procedural DML can specify and retrieve many records in a single DML statement. This retrieve of a record is said to be Set-at-a-time or Set-oriented.

38. What is Relational Algebra?

It is procedural query language. It consists of a set of operations that take one or two relations as input and produce a new relation.

39. What is Relational Calculus?

It is an applied predicate calculus specifically tailored for relational databases proposed by E.F. Codd. E.g. of languages based on it are DSL ALPHA, QUEL.

40. How does Tuple-oriented relational calculus differ from domain-oriented relational calculus?

1. The tuple-oriented calculus uses a tuple variables i.e., variable whose only permitted values are tuples of that relation. E.g. QUEL

2. The domain-oriented calculus has domain variables i.e., variables that range over the underlying domains instead of over relation. E.g. ILL, DEDUCE.

41. What is normalization?

It is a process of analysing the given relation schemas based on their Functional Dependencies (FDs) and primary key to achieve the properties(1).Minimizing redundancy, (2). Minimizing insertion, deletion and update anomalies.

82 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 83: General technical interview questions

42. What is Functional Dependency?

A Functional dependency is denoted by X Y between two sets of attributes X and Y that are subsets of R specifies a constraint on the possible tuple that can form a relation state r of R. The constraint is for any two tuples t1 and t2 in r if t1[X] = t2[X] then they have t1[Y] = t2[Y]. This means the value of X component of a tuple uniquely determines the value of component Y.

43. What is Lossless join property?

It guarantees that the spurious tuple generation does not occur with respect to relation schemas after decomposition.

44. What is 1 NF (Normal Form)?

The domain of attribute must include only atomic (simple, indivisible) values.

45. What is Fully Functional dependency?

It is based on concept of full functional dependency. A functional dependency X Y is full functional dependency if removal of any attribute A from X means that the dependency does not hold any more.

46. What is 2NF?

A relation schema R is in 2NF if it is in 1NF and every non-prime attribute A in R is fully functionally dependent on primary key.

47. What is 3NF?

A relation schema R is in 3NF if it is in 2NF and for every FD X A either of the following is true

1. X is a Super-key of R.2. A is a prime attribute of R.

In other words, if every non prime attribute is non-transitively dependent on primary key.

48. What is BCNF (Boyce-Codd Normal Form)?

A relation schema R is in BCNF if it is in 3NF and satisfies an additional constraint that for every FD X A, X must be a candidate key.

49. What is 4NF?

A relation schema R is said to be in 4NF if for every Multivalued dependency X Y that holds over R, one of following is true.1.) X is subset or equal to (or) XY = R.2.) X is a super key.

50. What is 5NF?

83 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 84: General technical interview questions

A Relation schema R is said to be 5NF if for every join dependency {R1, R2, ..., Rn} that holds R, one the following is true 1.) Ri = R for some i.2.) The join dependency is implied by the set of FD, over R in which the left side is key of R.

51. What is Domain-Key Normal Form?

A relation is said to be in DKNF if all constraints and dependencies that should hold on the the constraint can be enforced by simply enforcing the domain constraint and key constraint on the relation.

52. What are partial, alternate,, artificial, compound and natural key?

1. Partial Key: It is a set of attributes that can uniquely identify weak entities and that are related to same owner entity. It is sometime called as Discriminator.

2. Alternate Key: All Candidate Keys excluding the Primary Key are known as Alternate Keys.

3. Artificial Key: If no obvious key, either stand alone or compound is available, then the last resort is to simply create a key, by assigning a unique number to each record or occurrence. Then this is known as developing an artificial key.

4. Compound Key: If no single data element uniquely identifies occurrences within a construct, then combining multiple elements to create a unique identifier for the construct is known as creating a compound key.

5. Natural Key: When one of the data elements stored within a construct is utilized as the primary key, then it is called the natural key.

53. What is indexing and what are the different kinds of indexing?

Indexing is a technique for determining how quickly specific data can be found. Types:

1. Binary search style indexing2. B-Tree indexing3. Inverted list indexing4. Memory resident table5. Table indexing

54. What is system catalog or catalog relation? How is better known as?

A RDBMS maintains a description of all the data that it contains, information about every relation and index that it contains. This information is stored in a collection of relations maintained by the system called metadata. It is also called data dictionary.

55. What is meant by query optimization?

The phase that identifies an efficient execution plan for evaluating a query that has the least estimated cost is referred to as query optimization.

56. What is durability in DBMS?

84 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 85: General technical interview questions

Once the DBMS informs the user that a transaction has successfully completed, its effects should persist even if the system crashes before all its changes are reflected on disk. This property is called durability.

57. What do you mean by atomicity and aggregation?

1. Atomicity: Either all actions are carried out or none are. Users should not have to worry about the effect of incomplete transactions. DBMS ensures this by undoing the actions of incomplete transactions.

2. Aggregation: A concept which is used to model a relationship between a collection of entities and relationships. It is used when we need to express a relationship among relationships.

58. What is a Phantom Deadlock?

In distributed deadlock detection, the delay in propagating local information might cause the deadlock detection algorithms to identify deadlocks that do not really exist. Such situations are called phantom deadlocks and they lead to unnecessary aborts.

59. What is a checkpoint and When does it occur?

A Checkpoint is like a snapshot of the DBMS state. By taking checkpoints, the DBMS can reduce the amount of work to be done during restart in the event of subsequent crashes.

60. What are the different phases of transaction?

Different phases are1.) Analysis phase,2.) Redo Phase,3.) Undo phase.

61. What do you mean by flat file database?

It is a database in which there are no programs or user access languages. It has no cross-file capabilities but is user-friendly and provides user-interface management.

62. What is "transparent DBMS"?

It is one, which keeps its Physical Structure hidden from user.

63. What is a query?

A query with respect to DBMS relates to user commands that are used to interact with a data base. The query language can be classified into data definition language and data manipulation language.

64. What do you mean by Correlated subquery?

Subqueries, or nested queries, are used to bring back a set of rows to be used by the parent query. Depending on how the subquery is written, it can be executed once for the parent query or it can

85 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 86: General technical interview questions

be executed once for each row returned by the parent query. If the subquery is executed for each row of the parent, this is called a correlated subquery.

A correlated subquery can be easily identified if it contains any references to the parent subquery columns in its WHERE clause. Columns from the subquery cannot be referenced anywhere else in the parent query. The following example demonstrates a non-correlated subquery.

Example: Select * From CUST Where '10/03/1990' IN (Select ODATE From ORDER Where CUST.CNUM = ORDER.CNUM)

65. What are the primitive operations common to all record management systems?

Addition, deletion and modification.

66. Name the buffer in which all the commands that are typed in are stored?

'Edit' Buffer.

67. What are the unary operations in Relational Algebra?

PROJECTION and SELECTION.

68. Are the resulting relations of PRODUCT and JOIN operation the same?

No.PRODUCT: Concatenation of every row in one relation with every row in another.JOIN: Concatenation of rows from one relation and related rows from another.

69. What is RDBMS KERNEL?

Two important pieces of RDBMS architecture are the kernel, which is the software, and the data dictionary, which consists of the system-level data structures used by the kernel to manage the database You might think of an RDBMS as an operating system (or set of subsystems), designed specifically for controlling data access; its primary functions are storing, retrieving, and securing data. An RDBMS maintains its own list of authorized users and their associated privileges; manages memory caches and paging; controls locking for concurrent resource usage; dispatches and schedules user requests; and manages space usage within its table-space structures.

70. Name the sub-systems of a RDBMS.

I/O, Security, Language Processing, Process Control, Storage Management, Logging and Recovery, Distribution Control, Transaction Control, Memory Management, Lock Management.

71. Which part of the RDBMS takes care of the data dictionary? How?

Data dictionary is a set of tables and database objects that is stored in a special area of the database and maintained exclusively by the kernel.

72. What is the job of the information stored in data-dictionary?

86 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 87: General technical interview questions

The information in the data dictionary validates the existence of the objects, provides access to them, and maps the actual physical storage location.

73. How do you communicate with an RDBMS?

You communicate with an RDBMS using Structured Query Language (SQL).

74. Define SQL and state the differences between SQL and other conventional programming Languages.

SQL is a nonprocedural language that is designed specifically for data access operations on normalized relational database structures. The primary difference between SQL and other conventional programming languages is that SQL statements specify what data operations should be performed rather than how to perform them.

75. Name the three major set of files on disk that compose a database in Oracle.

There are three major sets of files on disk that compose a database. All the files are binary. These are

1.) Database files 2.) Control files3.) Redo logs

The most important of these are the database files where the actual data resides. The control files and the redo logs support the functioning of the architecture itself. All three sets of files must be present, open, and available to Oracle for any data on the database to be useable. Without these files, you cannot access the database, and the database administrator might have to recover some or all of the database using a backup, if there is one.

76. What is database Trigger?

A database trigger is a PL/SQL block that can defined to automatically execute for insert, update, and delete statements against a table. The trigger can e defined to execute once for the entire statement or once for every row that is inserted, updated, or deleted. For any one table, there are twelve events for which you can define database triggers. A database trigger can call database procedures that are also written in PL/SQL.

77. What are stored-procedures? And what are the advantages of using them?

Stored procedures are database objects that perform a user defined operation. A stored procedure can have a set of compound SQL statements. A stored procedure executes the SQL commands and returns the result to the client. Stored procedures are used to reduce network traffic.

78. What is Storage Manager?

It is a program module that provides the interface between the low-level data stored in database, application programs and queries submitted to the system.

79. What is Buffer Manager?

87 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 88: General technical interview questions

It is a program module, which is responsible for fetching data from disk storage into main memory and deciding what data to be cache in memory.

80. What is Transaction Manager?

It is a program module, which ensures that database, remains in a consistent state despite system failures and concurrent transaction execution proceeds without conflicting.

81. What is File Manager?

It is a program module, which manages the allocation of space on disk storage and data structure used to represent information stored on a disk.

82. What is Authorization and Integrity manager?

It is the program module, which tests for the satisfaction of integrity constraint and checks the authority of user to access data.

83. What are stand-alone procedures?

Procedures that are not part of a package are known as stand-alone because they independently defined. A good example of a stand-alone procedure is one written in a SQL*Forms application. These types of procedures are not available for reference from other Oracle tools. Another limitation of stand-alone procedures is that they are compiled at run time, which slows execution.

84. What are cursors give different types of cursors?

PL/SQL uses cursors for all database information accesses statements. The language supports the use two types of cursors1.) Implicit2.) Explicit

85. What is cold backup and hot backup (in case of Oracle)?

1. Cold Backup: It is copying the three sets of files (database files, redo logs, and control file) when the instance is shut down. This is a straight file copy, usually from the disk directly to tape. You must shut down the instance to guarantee a consistent copy. If a cold backup is performed, the only option available in the event of data file loss is restoring all the files from the latest backup. All work performed on the database since the last backup is lost.

2. Hot Backup: Some sites (such as worldwide airline reservations systems) cannot shut down the database while making a backup copy of the files. The cold backup is not an available option.

86. What is meant by Proactive, Retroactive and Simultaneous Update.

1. Proactive Update: The updates that are applied to database before it becomes effective in real world.

2. Retroactive Update: The updates that are applied to database after it becomes effective in real world.

88 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 89: General technical interview questions

3. Simulatneous Update: The updates that are applied to database at the same time when it becomes effective in real world.

Database Management System

1. What are data and information, and how are they related in a database?

Data is recorded facts and figures, and information is knowledge derived from data. A database stores data in such a way that information can be created.

2. What is Enterprise Resource Planning (ERP), and what kind of a database is used in an ERP application?

Enterprise Resource Planning (ERP) is an information system used in manufacturing companies and includes sales, inventory, production planning, purchasing and other business functions. An ERP system typically uses a multiuser database.

3. What is a DBMS?

DBMS stands for Database Management System. A DBMS receives requests from applications and translates those requests into actions on a specific database. A DBMS processes SQL statements or uses other functionality to create, process and administer databases.

4. Why is a database considered to be "self-describing"?

In addition to the users' data, a database contains a description of its own structure. This descriptive data is called "metadata."

5. Who is E.F. Codd, and why is he significant in the development of modern database systems?

89 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 90: General technical interview questions

While working at IBM, E.F. Codd created the relational database model. A paper he published in 1970 presented his ideas to the world at large. His work is the foundation for most of the DBMSs currently in use, and thus forms the basis for database systems as we know and use them today.

6. What is SQL, and why is it important?

SQL stands for Structured Query Language, and is the most important data processing language in use today. It is not a complete programming language like Java or C#, but a data sublanguage used for creating and processing database data and metadata. All DBMS products today use SQL.

7. Write an SQL SELECT statement to display all the columns of the STUDENT table but only those rows where the Grade column is greater than or equal to 90.

SELECT * FROM STUDENT WHERE Grade >= 90;

8. Name and briefly describe the five SQL built-in functions.

COUNT: computes the number of rows in a table. SUM: totals numeric columns. AVG: computes the average value. MAX: obtains the maximum value of a column in a table. MIN: obtains the minimum value of a column in a table.

9. Write an SQL SELECT statement to count the number of rows in STUDENT table and display the result with the label NumStudents.

SELECT COUNT(*) AS NumStudents FROM STUDENT;

10. What is an SQL subquery?

An SQL subquery is a means of querying two or more tables at the same time. The subquery itself is an SQL SELECT statement contained within the WHERE clause of another SQL SELECT statement, and separated by being enclosed in parenthesis. Some subqueries have equivalent SQL join structures, but correlated subqueries cannot be duplicated by a join..

11. Discuss the alternative terminology that is used in the relational model.

Relations are also called tables, and sometimes by the older data processing term files. A row is known as a tuple in the relational model, but may also be referred to as a record. Finally, relational model attributes are known as table columns and sometimes as fields.

12. Why are functional dependencies not equations?

Equations deal with numerical relationships. A functional dependency deals with the existence of a determinant relationship between attributes, regardless of whether or not there is a numerical relationship between them. Thus, if we know that there is no hot water every Wednesday, No-Hot-Water is functionally dependent on Wednesday. So, if we know it is Wednesday, then we know we will have No-Hot-Water. This is a functional dependency, but not an equation.

13. What is a foreign key, and what is it used for?

A foreign key is used to establish relationships among relations in the relational model. Technically, a foreign key is a column (or columns) appearing in one relation that is (are) the primary key of

90 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 91: General technical interview questions

another table. Although there may be exceptions, the values in the foreign key columns usually must correspond to values existing in the set of primary key values. This correspondence requirement is created in a database using a referential integrity constraint on the foreign key.

14. What are insertion and deletion anomalies?

A deletion anomaly occurs when, by deleting the facts about one entity, we inadvertently delete facts about another entity; with one deletion, we lose facts about two entities. For example, if we delete the tuple for Student 001289 from a table, we may lose not only the fact that Student 001289 is in Pierce Hall, but also the fact that he has $200 left in his security deposit. An insertion anomaly happens when we encounter the restriction that we cannot insert a fact about one entity until we have an additional fact about another entity. For example, we want to store the fact that the security deposit for Pierce Hall is $300, but we cannot enter this data into the Student relation until a student registers for Pierce Hall.

15. What does it mean when we say that a relation is in Boyce-Codd Normal Form (BCNF)?

A relation is in BCNF when every determinant in the relation is a candidate key. This means that any possible primary key can determine all other attributes in the relation. Attributes may not be determined by non-candidate key attributes or part of a composite candidate key. Thus it is said "I swear to construct my tables so that all nonkey columns are dependent on the key, the whole key and nothing but the key, so help me Codd!"

16. You have been given a set of tables with data and asked to create a new database to store them. When you examine the data values in the tables, what are you looking for?

(1) Multivalued dependencies, (2) Functional dependencies, (3) Candidate keys, (4) Primary keys and (5) Foreign keys.

17. Why do normalized tables require more complex SQL when SQL statements are used in application programs?

Tables that are normalized contain data that has been distributed among the tables, but which may need to be recombined to answer queries from an application. To recombine the data, the programmer will have to use subqueries and/or joins. These SQL structures are more complex to write than a simple SELECT statement.

18. What is the multivalue, multicolumn problem? Include an example not used in the text.

The multivalue, multicolumn problem occurs when a table is designed to include multiple columns that hold variations of one type of attribute data. One example is where boat owners have the names of their boats stored as BOAT_01, BOAT_02 and BOAT_03.

19. Why is the multivalue, multicolumn problem another form of the multivalued dependency problem?

Both problems try to store multiple values on an attribute in a table. In the multivalue, multiplecolumn problem, the multiple values are stored in different columns. In the mutlivalued

91 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 92: General technical interview questions

dependency problem the multiple values are stored in different rows. In both cases, the solution is the same: store the multiple values in a separate table.

20. What is the inconsistent values problem? Include an example not used in the text.

The inconsistent values problem occurs when different users or data sources use slightly different forms of the same data value. One example is where automobiles are specified as "Ford, 2-door, Red" in one cell and "Red Ford 2-door" in another.

21. Explain the relationship between entity, entity class, and entity instance.

An entity is something that can be identified in the users' work environment, something that the users want to track. Entities of a given type are grouped into entity classes. An entity instance is the representation of a particular entity.

22. Explain the difference between attributes and identifiers.

Entities have attributes. Attributes are properties that describe the entity's characteristics. Entity instances have identifiers. Identifiers are attributes that name, or identify, entity instances.

23. Name and describe three types of binary relationships.

1:1 - a single entity instance of one type is related to a single-entity instance of another type.

1:N - a single entity instance of one type is related to many-entity instances of another type.

M:N - many-entity instances of one type relate to many-entity instances of another type.

24. What is the archtetype/instance pattern?

The archetype/instance pattern occurs when one entity tracks occurrences of another entity. A common example is the relationship between CLASS and SECTION, where the actual occurrence of a class happens when students register for a SECTION of that CLASS. The archetype/instance pattern is implemented as an ID-dependent relationship.

25. What is a recursive relationship? Give an example not used in the text.

A recursive relationship is a relationship between an entity and itself. For example, given the entity PERSON, a recursive relationship could be used to show a PERSON and his or her SIBLINGs (brothers and sisters).

26. What are the steps for transforming an entity into a table?

The steps are: (1) specify the primary key, (2) specify candidate keys, (3) specify column properties including null status, data type, default value (if any), and data constraints (if any), and (4) verifying normalization.

27. Define a surrogate key, describe the ideal primary key and explain how surrogate keys meet this ideal.

92 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 93: General technical interview questions

The ideal primary key is short, numeric and fixed. A surrogate key is a unique, DBMS-supplied identifier intended to be used as the primary key of a table. Further, the DBMS will not allow the value of a surrogate key to be changed. The values of a surrogate key have no meaning to the users and are usually hidden on forms and reports. By design, they are short, numeric and fixed and thus meet the definition of the ideal primary key

28. Define and discuss data constraints.

Data constraints on a column are the limits put on the values the data can have. There are four types of data constraints: (1) domain constraints, which define a limited set of values for the column, (2) range constraints, which specify that the values must fall within a certain range, (3) intrarelation constraints, which define what values the column can have based on values of other columns in the same table, and (4) interrelation constraints, which define values the column can have based on values of columns in other tables.

29. In general, how are recursive relationships handled in a database design?

A recursive relationship is a relationship among entities of the same class, and is represented in the same way as other relationships are. The rows of the tables can take two different roles, however. Some are parent rows, and others are child rows. Further, the table will contain both its own primary key and the foreign key that links back to the table itself. If a row has no parent, then the value of the foreign key column in that row will be null. If the row has a parent, then there must be a foreign key value in that row that corresponds to the primary key value of another row in the table.

30. What is a cascading update?

Referential integrity constraints require that foreign key values in one table correspond to primary key values in another. If the value of the primary key is changed -- that is, updated -- the value of the foreign key must immediately be changed to match it. Cascading updates will set this change to be done automatically by the DBMS whenever necessary.

31. What is a SQL view? Briefly explain the use of views.

A SQL view is a virtual table built from other tables or views. Views are used to (1) hide columns or rows, (2) show the results of computed columns, (3) hide complicated SQL syntax, (4) layer built-in functions, (5) provide a level of indirection between application programs and tables, (6) assign different sets of processing permissions to tables, and (7) to assign different sets of triggers to the same table.

32. Explain the "paradigm mismatch" between SQL and application programming languages.

SQL statements return a set of rows, while an application program works on one row at a time. To resolve this mismatch the results of SQL statements are processed as pseudofiles, using a cursor or pointer to specify which row is being processed.

33. Name four applications for triggers.

(1) providing default values, (2) enforcing data constraints, (3) updating views and (4) enforcing referential integrity

93 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 94: General technical interview questions

34. What are stored procedures, and how do they differ from triggers?

A stored procedure is a program that is stored within the database and is compiled when used. They can receive input parameters and they can return results. Unlike triggers, their scope is database-wide; they can be used by any process that has permission to use the database stored procedure.

35. What are the advantages of using stored procedures?

The advantages of stored procedures are (1) greater security, (2) decreased network traffic, (3) the fact that SQL can be optimized and (4) code sharing which leads to less work, standardized processing, and specialization among developers.

36. Why is database redesign necessary?

Database redesign is necessary for two reasons. First, redesign is necessary both to fix mistakes made during the initial database design. Second, redesign is necessary to adapt the database to changes in system requirements. Such changes are common because information systems and organizations do not just influence each other they create each other. Thus, new information systems cause changes in systems requirements.

37. What is the difference between a correlated subquery and a regular subquery?

A correlated subquery appears deceptively similar to a regular subquery. The difference is that a regular subquery can be processed from the bottom up. In a regular subquery, results from the lowest query can be determined and used to evaluate the upper-level query. In contrast, in a correlated subquery, the processing is nested; that is, a row from an upper query statement is used in comparison with rows in a lower level query. The key distinction of a correlated subquery is that the lower-level select statements use columns from upper-level statements.

38. What is a dependency graph?

A dependency graph is a diagram that is used to portray the connections between database elements. For example, a change in a table can potentially impact relationships, views, indexes, triggers, stored procedures, and application programs. These impacts need to be known and accounted for before making database changes.

39. Explain how to add a NOT NULL column to a table.

First, add the column as NULL. Then use UPDATE to add data to every row. Finally use an ALTER TABLE . . . ALTER COLUMN statement to change the column constraint to NOT NULL.

40. You have two tables, EMPLOYEE and COMPUTER that are in a one-to-one relationship. The foreign key is EmpNumber in COMPUTER which references EmpNumber as the primary key of EMPLOYEE. Explain what must be done to convert the one-to-one EMPLOYEE-COMPUTER relationship to a one-to-many relationship where one employee can have more than one computer.

In the one-to-one relationship, there will be a constraint on EmpNumber as a foreign key in COMPUTER stating that EmpNumber must be unique. To convert the relationship to a one-to-many relationship, just drop this constraint.

94 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 95: General technical interview questions

41. Explain the difference between an exclusive lock and a shared lock.

An exclusive lock prohibits other users from reading the locked resource; a shared lock allows other users to read the locked resource, but they cannot update it.

42. Explain the difference between optimistic locking and pessimistic locking.

Optimistic locking assumes no transaction conflict will occur and deals with the consequences if it does. Pessimistic locking assumes that conflict will occur and so prevents it ahead of time with locks. In general, optimistic locking is preferred for the Internet and for many intranet applications.

43. What is deadlock? How can it be avoided? How can it be resolved once it occurs?

Deadlock occurs when two transactions are each waiting on a resource that the other transaction holds. Deadlock can be prevented by requiring transactions to acquire all locks at the same time; once it occurs, the only way to cure it is to abort one of the transactions and back out of partially completed work.

44. What are the major functions of the database administrator?

Managing database structure, controlling concurrent processing, managing processing rights and responsibilities, developing database security, providing for database recovery, managing the DBMS and maintaining the data repository.

45. Explain what we mean by an ACID transaction.

An ACID transaction is one that is atomic, consistent, isolated, and durable. Durable means that database changes are permanent. Consistency can mean either statement level or transaction level consistency. With transaction level consistency, a transaction may not see its own changes. There are four transaction isolation levels: read committed, read uncommitted, repeatable read and serialization. Atomic means it is performed as a unit.

46. What are the ways in which an Oracle database can be created?

There are three (3) ways to create an Oracle database. You can create a database using the Database Configuration Assistant, using the Oracle-supplied database creation procedures or using the SQL CREATE DATABASE command.

47. What are sequences, and what are the possible problems when using them to create surrogate keys?

A sequence is an object that generates a sequential series of unique numbers. Sequences are most often used to provide values for surrogate keys. However, there are three problems with using sequences. First, a developer can use a defined sequence for any purpose; and if a sequence is used for purposes other than the surrogate key, some values will be missing. A second problem is that there is nothing in the schema that prevents someone from issuing an INSERT statement that adds data to the table but that does not use the sequence. Finally, it is possible to use the wrong sequence when putting data into a table.

48. Under what conditions should indexes be used?

95 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 96: General technical interview questions

Indexes can be created to enforce uniqueness, to facilitate sorting, and to enable fast retrieval by column values. A good candidate for an index is a column that is frequently used with equal conditions in WHERE clauses.

49. Explain the three levels of transaction isolation supported by Oracle.

Oracle supports read committed, serializable, and read-only transaction isolation levels. Because of the way Oracle System Change Number (SCN) values are processed, Oracle never reads dirty data. Serializable isolation is possible, but the application program must be written to process the "Cannot serialize" exception. Applications can place locks explicitly using SELECT FOR UPDATE commands but this is not recommended.

50. What are the types of files used in Oracle recovery?

Datafiles, control files and two types of ReDo log files: OnLine Redo and Offline ReDo (which is also known as Archive ReDo).

51. What is the difference between SQL Server 2000 complete and differential backups?

A complete backup makes a copy of the entire database. A differential backup makes a copy of the changes that have been made to the database since the last complete backup. A complete backup must be made before the first differential backup. Because differential backups are faster, they can be taken more frequently and the chance of data loss is reduced. Complete backups take longer but are slightly simpler to use for recovery.

52. Explain the meaning of each of the transaction levels supported by SQL Server.

The strictest isolation level is SERIALIZABLE. With it, SQL Server places a range lock on the rows that have been read. This level is the most expensive to use and should only be used when absolutely required. The next most restrictive level is REPEATABLE READ, which means SQL Server places and holds locks on all rows that are read. It is possible to make dirty reads by setting the isolation level to READ UNCOMMITTED, which is the least restrictive level. READ COMMITTED is the default isolation level.

53. Explain the difference between the SQL Server 2000 simple, full, and bulk-logged recovery models.

With the simple recovery model, no logging is done. The only way to recover a database is to restore the database to the last backup. With full recovery, all database changes are logged. With bulk-logged database recovery, all changes are logged except those that cause large log entries.

54. What is the difference between SQL Server 2000 clustered and nonclustered indexes?

With a clustered index, the data are stored in the bottom level of the index and in the same order as that index. With a nonclustered index, the bottom level of an index does not contain data; it contains pointers to the data. For data retrieval, clustered indexes are faster than nonclustered indexes.

55. What triggers does SQL Server 2000 support?

96 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 97: General technical interview questions

SQL Server 2000 supports INSTEAD OF and AFTER triggers only. There is no SQL Server support for BEFORE triggers. A table may have one or more AFTER triggers for insert, update and delete actions; AFTER triggers may not be assigned to views. A view or table may have at most one INSTEAD OF trigger for each triggering action of insert, update or delete.

56. What is the relationship of ODBC, OLE DB, and ADO?

Developed first, the ODBC standard is for relational databases; while the OLE DB standard provides functionality for both relational and other databases. Finally, ADO was developed to provide easier access to OLE DB data for the non-object-oriented programmer.

57. What are the three types of data sources used with ODBC?

An ODBC file data source is a file that can be shared among database users. A ODBC system data source is one that is local to a single computer. A ODBC user data source is only available to the user who created it.

58. What disadvantage of ODBC does OLE DB overcome?

By breaking the features and the functions of a DBMS into COM objects, OLE DB characteristic overcomes a major disadvantage of ODBC. With ODBC, a vendor must create an ODBC driver for almost all DBMS features and functions in order to participate in ODBC at all. This is a large task that requires a substantial initial investment. With OLE DB, however, a DBMS vendor can implement portions of their product.

59. What are to goals of OLE DB?

The major goals of OLE DB are to: (1) Create object interfaces for DBMS functionality pieces; (2) Increase flexibility for developers and users; (3) provide an object interface over any type of data; and (4) do not force data to be converted or moved from where it is.

60. In OLE DB, what is the difference between an interface and an implementation?

An OLE DB interface is specified by a set of objects, and the properties and methods that they expose, and OLE DB defines standardized interfaces. An object need not expose all of its properties and methods in a given interface. An OLE DB implementation defines how the object supports the interface. The implementation is completely hidden from the user. Thus developers of an object are free to change the implementation whenever they want, but they should not change the interface without consulting their users.

61. Why is XML a better markup language than HTML?

XML is a better markup language than HTML, primarily because XML provides a clear separation between document structure, content, and materialization. Symbols cannot be used ambiguously with XML.

62. What are the two means to describe the content of XML documents?

DTD (Document Type Declarations) and XML Schemas. An XML document that conforms to its DTD is called type-valid. A document can be well-formed and not be type-valid, either because it violates the structure of its DTD or because it has no DTD. However, DTDs have limitations and to

97 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 98: General technical interview questions

overcome these limits XML Schemas were created. XML Schemas are XML documents that are the preferred method for defining document structure.

63. What is the difference between simple elements and complexType elements?

Simple elements have only one data value. ComplexType elements can have multiple elements nested within them. ComplexTypes may also have attributes. The elements contained in a complexType may be simple or other complexTypes. ComplexTypes may also define element sequences.

64. What is ADO.NET?

ADO.NET is a new, improved, and greatly expanded version of ADO that was developed for the Microsoft .NET initiative. ADO.NET incorporates all of the functionality of ADO, but adds much more. In particular, ADO.NET facilitates the transformation of XML documents to and from database data. Most importantly, ADO.NET introduces the concept of datasets, which are in-memory, full-function, independent databases.

65. What is a dataset?

A dataset is an in-memory database that is disconnected from any regular database, but has all the important characteristics of a regular database. Datasets can have multiple tables, relationships, referential integrity rules, referential integrity actions, views and the equivalent of triggers. Datasets are needed to provide a standardized, non-proprietary means to process database views. They are especially important for the processing of views with multiple multivalued paths.

66. Briefly describe the four JDBC driver types that Sun defines.

Type 1 drivers provide a bridge between Java and ODBC. Types 2-4 drivers are written entirely in Java, but differ as to how they connect to the DBMS. Type 2 drivers rely on the DBMS product for intermachine communication, if any. Type 3 drivers translate JDBC calls into a DBMS-independent network protocol. Type 4 drivers translate JDBC calls into a DBMS-dependent network protocol.

67. What is the difference between a Java servlet and a Java applet?

An applet is a compiled Java bytecode program that is transmitted to a browser via HTTP and is invoked using the HTTP protocol on the user's workstation. A servlet is a Java program that is invoked on the server to respond to HTTP requests.

68. What is the coding pattern for using a JDBC driver?

1. Load the driver.

2. Establish a connection to the database.

3. Create a statement.

4. Do something with the statement.

69. What is a Java bean?

98 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 99: General technical interview questions

A Java bean is a Java class that has the following three properties. (1) There are no public instance variables. (2) All persistent values are accessed using methods named getxxx and setxxx. (3) The bean class must either have no constructors or it must have one explicitly defined zero-argument constructor.

70. How are surrogate keys and metadata handled in MySQL?

MySQL uses integer data types combined with the property AUTO_INCREMENT to create surrogate keys. This creates a sequence that starts at one (1) and increases by one (1) for each new record. MySql maintain its metadata in a database named mysql. For example, this database maintains two tables named user and db.

71. What is a data mart?

A data mart is a collection of data smaller in scope and size than a data warehouse. It is dedicated to data from a particular business component of business functional area. A data mart may function as a subset of a larger data warehouse. Users of a data mart are usually knowledgeable analysts in the business area using the data mart.

72. What is RFM analysis?

RFM analysis is a Business Intelligence (BI) reporting system that analyzes and ranks customers based on their purchasing patterns. R refers to "how recently" a customer placed an order, F refers to "how frequently" the customer orders, and M refers to "how much money" the customer spends. Typically, the customers are ranked into "20%" groups and assigned a number to represent their ranking. Thus 1 means top 20%, 2 the next 20% and so on. In this system a score of 1 is best and a score of 5 is worst. Thus a customer with an RFM score = 1 5 1 would be one who has ordered recently, does not order frequently, and who makes large purchases.

73. What are the functions of a reporting system?

A reporting system has three functions: 1. Report authoring -- connecting to data sources, creating the report structure and formatting the report. 2. Report management -- defining who receives which reports, when they receive them and how the reports are delivered. 3. Report delivery -- based on report management metadata, either pushing the reports to the recipients or allowing them to be pulled by the recipients.

74. What is OLAP?

OnLine Analytical Processing (OLAP) is a Business Intelligence (BI) reporting system. OLAP provides the user with the capability to sum, count, average and do other simple arithmetic operations on groups of data. An OLAP report has measures and dimensions. Measures are the data values to be displayed. Dimensions are characteristics of the measures. OLAP reports are called OLAP cubes, although such reports are not limited to three dimensions.

75. What is market basket analysis?

Market basket analysis is a data mining technique that determines which sets of products tend to be purchased together. A common technique uses conditional probabilities. In addition to the basic probability that an item will be purchased, three results are of particular interest:

99 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 100: General technical interview questions

Support -- the probability of two items being purchased together.

Confidence -- the probability of a second item being purchased GIVEN that another item has been purchased.

Lift -- calculated as confidence divided by a basic probability, this shows the likelihood of a second item being purchased IF an item is purchased.

76. Explain the differences between structured data and unstructured data.

Structured data are facts concerning objects and events. The most important structured data are numeric, character, and dates. Structured data are stored in tabular form. Unstructured data are multimedia data such as documents, photographs, maps, images, sound, and video clips. Unstructured data are most commonly found on Web servers and Web-enabled databases.

77. Explain why it is still necessary to have at least some familiarity with file processing systems even though it has become evident that traditional file processing systems have a number of shortcomings and limitations.

Many businesses still use file processing systems today. This is especially true in the creation of backups for a database system. In addition, if you understand some of the limitations of a file processing system such as program-data dependence, duplication of data, limited data sharing, lengthy development times, and excessive program maintenance, you can try and avoid them as you design and develop a databases.

78. What are some of the disadvantages associated with conventional file processing systems?

There are five disadvantages. Program-data dependence occurs when file descriptions need to be changed in all programs whenever a file description changes. Duplication of data is storing the data more than one time. Limited data sharing occurs when the files are private so no one outside of one application can access the data. Lengthy development times exist because file processing systems takes longer to develop. Lastly, excessive program maintenance exists since the effort to maintain a program is larger in this environment.

79. The range of database applications can be divided into five categories. Explain the five different categories.

Databases can support from a single user (personal database) up to supporting the requests of the world (internet database). In between, a database can support a workgroup (a relatively small group of people), department database (a functional unit in an organization such as marketing), or an enterprise database (entire organization).

80. Explain the differences between an intranet and an extranet.

An Internet database is accessible by everyone who has access to a Web site. An intranet database limits access to only people within a given organization. An extranet database limits access to only people within a company and a company's customers and suppliers.

81. Briefly explain the five components of an Information Systems Architecture and their relationship to data.

100 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 101: General technical interview questions

Processes that manipulate the data. Networks that transport the data. People who process and use the data. Events and point in time when processes need to be performed with the data. Reasons for events and rules to govern the processing of the data.

82. Explain the systems development life cycle.

This is the traditional method to develop, maintain, and replace information systems that includes the project identification and selection, project initiation and planning, analysis, logical design, physical design, implementation, and maintenance steps. The process is a series of steps that are ideally completed in a linear fashion. In reality, the process is not linear and the process requires steps to be revisited and an overlap of steps.

83. Explain the differences of the two principal types of packaged data models.

Universal data models are common to many organizations. These models may be useful for similar functions that are used across companies or organizations such as purchasing and accounting. Industry-specific data models are used by specific industries.

84. Who can make up a systems or database team? Provide a brief explanation of each.

The team includes a system analyst who identifies the need for information services to meet opportunities of the business, database analysts who design the database, users who monitor that the system will meet their needs, programmers who write computer programs, database and data administrators who have responsibility for current and future databases and other technical experts.

85. Briefly describe the six database activities that occur during the systems development life cycle.

The enterprise modeling that analyzes the current data processing. Conceptual data modeling that identifies entities, relationships, and attributes. The logical database design that identifies data integrity and security requirements. The physical database design and definition that defines the database to a DBMS. The database implementation that installs and converts data from prior systems. Database maintenance that fixes errors in the database and database applications.

86. Briefly explain an ERD.

An ERD is a detailed logical representation of the data for an organization. The ERD includes entities, attributes, relationships, and cardinalities. An ERD is the mechanism where an entity-relationship model is displayed.

87. List some of the chrematistics of good data definitions.

Definitions are gathered from the same sources and should be accompanied diagrams. A definition will include special conditions, examples, how the data is created, whether the data can change, who owns the data, whether the data is optional, and whether the data can be broken into something more atomic.

88. Explain minimum and maximum cardinality.

101 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 102: General technical interview questions

Minimum cardinality is the minimum number of instances of an entity that can be associated with each instance of another entity. Maximum cardinality is the maximum number of instances of an entity that can be associated with each instance of another entity.

89. Describe the naming of Relationships?

Relationships are verb phrases and represent actions usually in the present tense. The name should exclude vague names such as "has". The name should explain what action is being taken and possibly why it is important.

90. Why is modeling time-dependent data with a time stamp important?

The values of data may change. A time stamp helps to ensure that the previous value of the data stays in the database after it has changed so that you can see the before and after values through time. Without a time stamp, you will most likely lose some of the history.

91. Explain the difference between total specialization and partial specialization.

Total specialization exists when every instance of a supertype must also be an instance of a subtype. Partial specialization exists when every instance of a supertype does not have to be an instance of a subtype.

92. Explain the difference between an ERD and EER.

An EER includes everything in an ERD and an EER allows for more complex relationships than an ERD. An EER allows for object-oriented data modeling and include supertypes and subtypes entities and inheritance.

93. Explain the difference between the disjoint and overlap rule.

The disjoint rule states an entity instance of a supertype can only be a member of one subtype. The overlap rule states an entity instance of a supertype can be a member of multiple subtypes.

94. List the three types of business rules and define each of them.

A derivation is a statement that is derived from other knowledge. A structured assertion is a statement that expresses some aspect of the static structure of an organization. An action assertion is a statement of a constraint on the actions of an organization.

95. Explain how a scenario is used for business rules.

A scenario is used to test business rules. It is a short script that describes how a business reacts to certain situations.

96. Explain some of the main goals of normalization.

Normalization should minimize data redundancy. It should also simplify referential integrity constraints. Normalization will also make it easier to insert, update, and delete data. And finally, it provides better design.

97. List some of the properties of a relation.

102 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 103: General technical interview questions

Relations in a database have a unique name and no multivalued attributes exist. Each row is unique and each attribute within a relation has a unique name. The sequence of both columns and rows is irrelevant.

98. Explain what needs to happen to convert a relation to third normal form

First you must verify that a relation is in both first normal form and second normal form. If the relation is not, you must convert into second normal form. After a relation is in second normal form, you must remove all transitive dependencies.

99. Describe how a supertype/subtype relationship is mapped into a relation.

A separate relation is created for each supertype and subtype. The attributes common for all of the subtypes are assigned to the supertype. Each subtype has the primary key from the supertype assigned to it. A subtype discriminator is added to the supertype.

100. Describe domain constraints.

Domain constraints include entity integrity and referential integrity. The domain is a set of values that may be assigned to an attribute. The entity integrity rule states that no part of a primary key cannot be null. Referential integrity states that each foreign key value must match a primary key value or be null.

101. What are the four objectives of the selection of a data type?

A data type should be selected so that all possible values are represented using minimal storage space. The data type should help to ensure data integrity and support all possible data manipulations (i.e., cannot place a letter in a field such as salary where a number is required).

102. Describe the four types of indexes.

A unique primary index is unique and is used to find and store a row. A nonunique primary index is not unique and is used to find a row but also where to store a row (based on its unique primary index). A unique secondary index is unique for each row and used to find table rows. A nonunique secondary index is not unique and used to find table rows.

103. What is denormalization and why would someone consider doing so?

Denormalization is the process of taking normalized relations and changing them so that they are not longer normalized. This process may lead to anomalies and create data redundancy as negative consequences. However, the revised relations should improve database performance.

104. Compare a hierarchical and network database model?

The hierarchical model is a top-down structure where each parent may have many children but each child can have only one parent. This model supports one-to-one and one-to-many relationships. The network model can be much more flexible than the hierarchical model since each parent can have multiple children but each child can also have multiple parents. This model supports one-to-one, one-to-many, and many-to-many relationships.

105. Describe the differences between vertical and horizontal portioning.

103 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 104: General technical interview questions

Horizontal portioning is where the rows in a relation are separated by some criteria and placed into a new relation or file with the same layout as the original relation (in this case only the records in each file differ). Vertical portioning is where the columns in a relation are separated by some criteria and placed into a new relation or file with a different layout as the original relation.

106. Explain the difference between a dynamic and materialized view.

A dynamic view may be created every time that a specific view is requested by a user. A materialized view is created and or updated infrequently and it must be synchronized with its associated base table(s).

107. Discuss some of the techniques that can be used to tune operational performance.

Choosing primary and secondary keys can increase the speed of row selection, joining, and row ordering. Selecting the appropriate file organization for base tables and indexes can also improve performance. Clustering related rows together and maintaining statistics about tables and indexes can lead to increased efficiency.

108. Briefly describe the three types of SQL commands.

Data definition language commands are used to create, alter, and drop tables. Data manipulation commands are used to insert, modify, update, and query data in the database. Data control language commands help the DBA to control the database.

109. What are the steps to follow when preparing to create a table?

1. Identify the data type, length, and precision for each attribute. 2. Identify the columns that can accept a null value. 3. Identify the columns that need to be unique. 4. Identify primary and related foreign keys with the parent table being created before the child. 5. Determine default values. 6. Determine where the domain values are that need to be constrained. 7. Create the indexes.

110. What are some disadvantages of a standard language such as SQL?

A standard language can hinder the effort to create a new language. One standard is never enough to meet all of the business needs. A standard can be a compromise among interested parties which can cause the standard to not be ideal. If a standard is altered by some, than portability between platforms could be hurt.

111. Explain a join between tables

A join allows tables to be linked to other tables when a relationship between the tables exists. The relationships are established by using a common column in the tables and often uses the primary/foreign key relationship.

112. Describe and contrast a trigger and a procedure.

Triggers are stored and controlled in the DBMS. A trigger is executed automatically when a condition is met (INSERT, UPDATE, or DELETE). A procedure is also stored in a database. A procedure is not executed automatically.

113. Briefly describe an outer join.

104 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 105: General technical interview questions

An outer join includes the records that match and those that do not have a matching value in another table. Outer joins can be a LEFT outer join (includes all records from the first table listed) or a RIGHT outer join (includes all records from the second table listed). Outer joins are not easily used with more than two tables.

114. Describe a subquery.

A subquery is a query that is composed of two queries. The first query (inner query) is within the WHERE clause of the other query (outer query). In some cases the inner query provides results for the outer query to process. In other cases, the outer query results provide results for the inner query (correlated subquery).

115. Describe the difference between embedded and dynamic SQL.

Embedded SQL is the process of including hard coded SQL statements. These statements do not change unless the source code is modified. Dynamic SQL is the process of generating SQL on the fly. The statements generated do not have to be the same each time.

116. Explain the difference between two and three-tier architectures.

A three-tier architecture includes a client and two server layers. The application code is stored on the application server and the database is stored on the database server. A two-tier architecture includes a client and one server layer. The database is stored on the database server.

117. Describe and contrast SQL and QBE.

QBE is a direct-manipulation database language that uses a graphical approach to query construction. Some database systems translate QBE queries into SQL. QBE does not adhere to a standard but SQL does. Both SQL and QBE are relational database languages.

118. Describe ODBC

ODBC is a standard that contains an interface that provides a common language for application programs to access and process SQL databases. In order to use ODBC, a driver, server name, database name, user id, and password are required. ODBC is important for Internet applications and has gained wide acceptance.

119. Compare a thin and a fat client.

A fat client is a PC that is responsible where most processing occurs on the client rather than the server. Some of the fat client activities include processing, presentation logic, and business rules logic. A thin client is a PC where only limited processing occurs. In these cases, more processing should occur on the application server.

120. Describe some reasons that someone familiar with Microsoft Access will want to learn VBA.

You can perform more complex functions and error handling can be accommodated by VBA. VBA code will execute faster since code runs faster than macros and maintenance is easier because VBA modules are stored with the forms and reports. Reading VBA is easier because you can see the entire code. Finally, you can pass parameters and use OLE automation better.

105 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 106: General technical interview questions

121. Describe middleware applications that ease the connection of databases to Web applications.

Both ASP and ColdFusion are middleware that ease the connection of databases to Web applications. Both require the use of several files. Both use tags and are executed on the server. Both Internet Explorer and Netscape can access these files. The programmer does not need to be concerned with the client when they work with this middleware.

122. Describe JavaScript and VBScript.

JavaScript shares many features with Java. Developers use it to achieve interactivity. JavaScript is an open language and does not require a license. It is supported by both Internet Explorer and Netscape. VBScript is similar to JavaScript. It is based on Visual Basic but is simpler. Microsoft developed this language.

123. Describe Web Services.

Web Services are improving the ability of computers to communicate over the Internet. These services use XML programs and usually run in the background. Easier integration of applications may be possible because developers do not need to be familiar with the technical details with applications that are being integrated. UDDI is a technical specification for creating a distributed registry of Web services and businesses that are open to communicating through Web services.

124. Provide an overview of XML.

XML is used to structure and manipulate data involved with a browser and is becoming the standard for e-commerce. XML uses tags that are similar to HTML in that they use the angle brackets, but XML describes the content whereas HTML describes the appearance. The XML schema standard was published in May 2001 by W3C.

125. Describe Website security issues.

Website security issues include unauthorized access to the several aspects of one's Website. Security measures should include all aspects of the system such as the network, operating level, database, and Web server. Regular monitoring and security testing by a company should help to avoid intrusion into one's system.

126. Explain the role of metadata for the three-layer architecture.

Each of the three layers has a metadata layer linked with it. The metadata layer describes the properties or characteristics of the data. The operational metadata describe the data used in the various operational and external systems. The enterprise data warehouse metadata describe the reconciled data layer. The data mart metadata describes the derived data layer.

127. Describe why operational and informational systems are separate.

Operational systems are used to run the business in real time on a daily basis and contain current data. Non-managers and non-analysts work in this type of system. Operational systems must process large volumes of data. Informational systems are used to support decisions and contain historical data. Managers and analysts work in this type of system. Informational systems have periodic batch updates.

106 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 107: General technical interview questions

128. Describe a data warehouse.

A data warehouse is organized around specific subjects. The data is defined using consistent naming, format, and encoding structure standards. The data contains a time element, so that the data can be studied for trends. No data in a data warehouse can be updated by end users.

129. Explain why an information gap exists in most organizations.

One reason that an information gap exists is the fact that systems have been developed in separate, segmented efforts. This has helped the data from being stored in an integrated database and thus the data is in an inconsistent structure. The other reason for the gap is that most systems are created to support the operational aspect of an organization. The systems were not developed for decision making.

130. Describe the differences between a data warehouse and data mart.

A data warehouse is for the enterprise and contains multiple subjects. A data mart is for a specific functional area and focuses on one subject. A data warehouse is flexible and data-oriented and contains detailed historical data. A data mart is restrictive and project-oriented and contains some historical data.

131. Describe the difference between data and database administration.

Data administration is responsible for the overall management of data resources. Some of the core roles include the creation of data polices, procedures and standards, resolve data ownership issues, and manage the information repository. Database administration is physical database oversight. Some of the core duties include the selection of the DBMS and software tools, the installation and upgrade of the DBMS, and database performance tuning.

132. What are some of the important security features of a DBMS?

One of the features includes the use of views which allows the presentation of only data needed by someone and limits the capability of database updates. The use of integrity controls includes such things as domains, assertions, and checks. Also authorization rules, user-defined procedures, encryption, authentication schemes, and backups are important.

133. Describe concurrency control.

Concurrency control is the process managing simultaneous operations against a database so that database integrity is not compromised. There are two approaches to concurrency control. The pessimistic approach involves locking and the optimistic approach involves versioning.

134. Explain locking.

Locking is denying others the ability to update a record until someone completes the update or releases the record. Locking can occur on many different levels in a database. It can occur at the database, table, record, or field level. A lock can be shared (another can read the record while an update is in progress) or exclusive (no one can read the record while an update is in progress).

135. Explain issues for database performance.

107 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 108: General technical interview questions

The installation of the database is an important issue since the better the installation, the better the performance could be. Memory usage is learning how the DBMS uses main memory and then using that knowledge to enable better performance. I/O is usually very intense in a DB, so understanding how users will use the data will help to prepare the database better. CPU usage and application tuning are also important considerations.

136. Describe the difference between homogeneous and heterogeneous distributed database.

A homogenous database is one that uses the same DBMS at each node. Either each node can work independently or a central DBMS may coordinate database activities. A heterogeneous database is one that may have a different DBMS at each node. It may support some or all of the functionality of one logical database. It may support full Distributed DBMS functionality or partial Distributed DBMS functionality.

137. What is a distributed database?

A distributed database is a single logical database that is spread across more than one node or locations that are all connected via some communication link. It requires multiple DBMSs, running at each remote site. A distributed database can be either homogenous (same DBMS at each node) or heterogeneous (different DBMS at some nodes).

138. What is the difference between horizontal and vertical partitioning?

Horizontal partitioning is where some rows of a table are placed into the base relations at one site and other rows are placed at another site. Vertical partitioning is where some columns of a table are placed into the base relations at one site and other columns are placed at another site but each all of these relations must share a common domain.

139. Explain concurrency transparency.

Concurrency transparency is where each transaction in a distributed database is treated as if it is the only one in the system. Therefore if several transactions are running at one time, the results will be the same as if each transaction was run in serial order. The transaction manager helps to provide concurrency control. The three methods that may be used are locking, versioning, and timestamping.

140. Explain snapshot replication.

Snapshot replication can be used when an application does not require that the data always be current. These applications can be updated by periodic table copying or snapshots. As part of the snapshot effort, all of the data to be included in the snapshot is collected at a primary point. Then a read-only snapshot is taken and the snapshot is sent to each site so that the update can be made.

108 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 109: General technical interview questions

Core Java

1. What is the most important feature of Java?

Java is a platform independent language.

2. What do you mean by platform independence?

Platform independence means that we can write and compile the java code in one platform (eg Windows) and can execute the class in any other supported platform eg (Linux,Solaris,etc).

3. What is a JVM?

JVM is Java Virtual Machine which is a run time environment for the compiled java class files.

4. Are JVM's platform independent?

JVM's are not platform independent. JVM's are platform specific run time implementation provided by the vendor.

5. What is the difference between a JDK and a JVM?

JDK is Java Development Kit which is for development purpose and it includes execution environment also. But JVM is purely a run time environment and hence you will not be able to compile your source files using a JVM.

6. What is a pointer and does Java support pointers?

Pointer is a reference handle to a memory location. Improper handling of pointers leads to memory leaks and reliability issues hence Java doesn't support the usage of pointers.

7. What is the base class of all classes?

java.lang.Object

8. Does Java support multiple inheritance?

Java doesn't support multiple inheritance.

9. Is Java a pure object oriented language?

Java uses primitive data types and hence is not a pure object oriented language.

10. Are arrays primitive data types?

In Java, Arrays are objects.

11. What is difference between Path and Classpath?

Path and Classpath are operating system level environment variales. Path is used define where the system can find the executables(.exe) files and classpath is used to specify the location .class files.

109 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 110: General technical interview questions

12. What are local variables?

Local varaiables are those which are declared within a block of code like methods. Local variables should be initialised before accessing them.

13. What are instance variables?

Instance variables are those which are defined at the class level. Instance variables need not be initialized before using them as they are automatically initialized to their default values.

14. How to define a constant variable in Java?

The variable should be declared as static and final. So only one copy of the variable exists for all instances of the class and the value can't be changed also.static final int PI = 2.14; is an example for constant.

15. Should a main() method be compulsorily declared in all java classes?

No not required. main() method should be defined only if the source class is a java application.

16. What is the return type of the main() method?

Main() method doesn't return anything hence declared void.

17. Why is the main() method declared static?

main() method is called by the JVM even before the instantiation of the class hence it is declared as static.

18. What is the arguement of main() method?

main() method accepts an array of String object as arguement.

19. Can a main() method be overloaded?

Yes. You can have any number of main() methods with different method signature and implementation in the class.

20. Can a main() method be declared final?

Yes. Any inheriting class will not be able to have it's own default main() method.

21. Does the order of public and static declaration matter in main() method?

No. It doesn't matter but void should always come before main().

22. Can a source file contain more than one class declaration?

Yes a single source file can contain any number of Class declarations but only one of the class can be declared as public.

110 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 111: General technical interview questions

23. What is a package?

Package is a collection of related classes and interfaces. package declaration should be first statement in a java class.

24. Which package is imported by default?

java.lang package is imported by default even without a package declaration.

25. Can a class declared as private be accessed outside it's package?

Not possible.

26. Can a class be declared as protected?

The protected access modifier cannot be applied to class and interfaces. Methods, fields can be declaredprotected, however methods and fields in a interface cannot be declared protected.

27. What is the access scope of a protected method?

A protected method can be accessed by the classes within the same package or by the subclasses of the class in any package.

28. What is the purpose of declaring a variable as final?

A final variable's value can't be changed. final variables should be initialized before using them.

29. What is the impact of declaring a method as final?

A method declared as final can't be overridden. A sub-class can't have the same method signature with a different implementation.

30. I don't want my class to be inherited by any other class. What should i do?

You should declared your class as final. But you can't define your class as final, if it is an abstract class. A class declared as final can't be extended by any other class.

31. Can you give few examples of final classes defined in Java API?

java.lang.String, java.lang.Math are final classes.

32. How is final different from finally and finalize()?

final is a modifier which can be applied to a class or a method or a variable. final class can't be inherited,final method can't be overridden and final variable can't be changed. 

finally is an exception handling code section which gets executed whether an exception is raised or not by the try block code segment. 

finalize() is a method of Object class which will be executed by the JVM just before garbage collecting object to give a final chance for resource releasing activity.

111 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 112: General technical interview questions

33. Can a class be declared as static?

We can not declare top level class as static, but only inner class can be declared static.

public class Test{ static class InnerClass { public static void InnerMethod() { System.out.println("Static Inner Class!"); } } public static void main(String args[]) { Test.InnerClass.InnerMethod(); }}//output: Static Inner Class!

34. When will you define a method as static?

When a method needs to be accessed even before the creation of the object of the class then we should declare the method as static.

35. What are the restriction imposed on a static method or a static block of code?

A static method should not refer to instance variables without creating an instance and cannot use "this" operator to refer the instance.

36. I want to print "Hello" even before main() is executed. How will you acheive that?

Print the statement inside a static block of code. Static blocks get executed when the class gets loaded into the memory and even before the creation of an object. Hence it will be executed before the main() method. And it will be executed only once.

37. What is the importance of static variable?

static variables are class level variables where all objects of the class refer to the same variable. If one object changes the value then the change gets reflected in all the objects.

38. Can we declare a static variable inside a method?

Static varaibles are class level variables and they can't be declared inside a method. If declared, the class will not compile.

39. What is an Abstract Class and what is it's purpose?

A Class which doesn't provide complete implementation is defined as an abstract class. Abstract classes enforce abstraction.

40. Can a abstract class be declared final?

112 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 113: General technical interview questions

Not possible. An abstract class without being inherited is of no use and hence will result in compile time error.

41. What is use of a abstract variable?

Variables can't be declared as abstract. only classes and methods can be declared as abstract.

42. Can you create an object of an abstract class?

Not possible. Abstract classes can't be instantiated.

43. Can a abstract class be defined without any abstract methods?

Yes it's possible. This is basically to avoid instance creation of the class.

44. Class C implements Interface I containing method m1 and m2 declarations. Class C has provided implementation for method m2. Can i create an object of Class C?

No not possible. Class C should provide implementation for all the methods in the Interface I. Since Class C didn't provide implementation for m1 method, it has to be declared as abstract. Abstract classes can't be instantiated.

45. Can a method inside a Interface be declared as final?

No not possible. Doing so will result in compilation error. public and abstract are the only applicable modifiers for method declaration in an interface.

46. Can an Interface implement another Interface?

Intefaces doesn't provide implementation hence a interface cannot implement another interface.

47. Can an Interface extend another Interface?

Yes an Interface can inherit another Interface, for that matter an Interface can extend more than one Interface.

48. Can a Class extend more than one Class?

Not possible. A Class can extend only one class but can implement any number of Interfaces.

49. Why is an Interface be able to extend more than one Interface but a Class can't extend more than one Class?

Basically Java doesn't allow multiple inheritance, so a Class is restricted to extend only one Class. But an Interface is a pure abstraction model and doesn't have inheritance hierarchy like classes(do remember that the base class of all classes is Object). So an Interface is allowed to extend more than one Interface.

50. Can an Interface be final?

Not possible. Doing so so will result in compilation error.

113 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 114: General technical interview questions

51. Can a class be defined inside an Interface?

Yes it's possible.

52. Can an Interface be defined inside a class?

Yes it's possible.

53. What is a Marker Interface?

An Interface which doesn't have any declaration inside but still enforces a mechanism.

54. Which object oriented Concept is achieved by using overloading and overriding?

Polymorphism.

55. Why does Java not support operator overloading?

Operator overloading makes the code very difficult to read and maintain. To maintain code simplicity, Java doesn't support operator overloading.

56. Can we define private and protected modifiers for variables in interfaces?

No.

57. What is Externalizable?

Externalizable is an Interface that extends Serializable Interface. And sends data into Streams in Compressed Format. It has two methods, writeExternal(ObjectOuput out) and readExternal(ObjectInput in)

58. What modifiers are allowed for methods in an Interface?

Only public and abstract modifiers are allowed for methods in interfaces.

59. What is a local, member and a class variable?

Variables declared within a method are "local" variables.

Variables declared within the class i.e not within any methods are "member" variables (global variables).

Variables declared within the class i.e not within any methods and are defined as "static" are class variables.

60. What is an abstract method?

An abstract method is a method whose implementation is deferred to a subclass.

61. What value does read() return when it has reached the end of a file?

114 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 115: General technical interview questions

The read() method returns -1 when it has reached the end of a file.

62. Can a Byte object be cast to a double value?

No, an object cannot be cast to a primitive value.

63. What is the difference between a static and a non-static inner class?

A non-static inner class may have object instances that are associated with instances of the class's outer class. A static inner class does not have any object instances.

64. What is an object's lock and which object's have locks?

An object's lock is a mechanism that is used by multiple threads to obtain synchronized access to the object. A thread may execute a synchronized method of an object only after it has acquired the object's lock. All objects and classes have locks. A class's lock is acquired on the class's Class object.

65. What is the % operator?

It is referred to as the modulo or remainder operator. It returns the remainder of dividing the first operand by the second operand.

66. When can an object reference be cast to an interface reference?

An object reference be cast to an interface reference when the object implements the referenced interface.

67. Which class is extended by all other classes?

The Object class is extended by all other classes.

68. Which non-Unicode letter characters may be used as the first character of an identifier?

The non-Unicode letter characters $ and _ may appear as the first character of an identifier

69. What restrictions are placed on method overloading?

Two methods may not have the same name and argument list but different return types.

70. What is casting?

There are two types of casting, casting between primitive numeric types and casting between object references. Casting between numeric types is used to convert larger values, such as double values, to smaller values, such as byte values. Casting between object references is used to refer to an object by a compatible class, interface, or array type reference.

71. What is the return type of a program's main() method?

void.

115 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 116: General technical interview questions

72. If a variable is declared as private, where may the variable be accessed?

A private variable may only be accessed within the class in which it is declared.

73. What do you understand by private, protected and public?

These are accessibility modifiers. Private is the most restrictive, while public is the least restrictive. There is no real difference between protected and the default type (also known as package protected) within the context of the same package, however the protected keyword allows visibility to a derived class in a different package.

74. What is Downcasting ?

Downcasting is the casting from a general to a more specific type, i.e. casting down the hierarchy

75. What modifiers may be used with an inner class that is a member of an outer class?

A (non-local) inner class may be declared as public, protected, private, static, final, or abstract.

76. How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?

Unicode requires 16 bits and ASCII require 7 bits Although the ASCII character set uses only 7 bits, it is usually represented as 8 bits.

UTF-8 represents characters using 8, 16, and 18 bit patterns.

UTF-16 uses 16-bit and larger bit patterns.

77. What restrictions are placed on the location of a package statement within a source code file?

A package statement must appear as the first line in a source code file (excluding blank lines and comments).

78. What is a native method?

A native method is a method that is implemented in a language other than Java.

79. What are order of precedence and associativity, and how are they used?

Order of precedence determines the order in which operators are evaluated in expressions. Associatity determines whether an expression is evaluated left-to-right or right-to-left.

80. Can an anonymous class be declared as implementing an interface and extending a class?

An anonymous class may implement an interface or extend a superclass, but may not be declared to do both.

81. What is the range of the char type?

116 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 117: General technical interview questions

The range of the char type is 0 to 216 - 1 (i.e. 0 to 65535.)

82. What is the range of the short type?

The range of the short type is -(215) to 215 - 1. (i.e. -32,768 to 32,767)

83. Why isn't there operator overloading?

Because C++ has proven by example that operator overloading makes code almost impossible to maintain.

84. What does it mean that a method or field is "static"?

Static variables and methods are instantiated only once per class. In other words they are class variables, not instance variables. If you change the value of a static variable in a particular object, the value of that variable changes for all instances of that class. Static methods can be referenced with the name of the class rather than the name of a particular object of the class (though that works too). That's how library methods likeSystem.out.println() work. out is a static field in the java.lang.System class.

85. Is null a keyword?

The null value is not a keyword.

86. Which characters may be used as the second character of an identifier, but not as the first character of an identifier?

The digits 0 through 9 may not be used as the first character of an identifier but they may be used after the first character of an identifier.

87. Is the ternary operator written x : y ? z or x ? y : z ?

It is written x ? y : z.

88. How is rounding performed under integer division?

The fractional part of the result is truncated. This is known as rounding toward zero.

89. If a class is declared without any access modifiers, where may the class be accessed?

A class that is declared without any access modifiers is said to have package access. This means that the class can only be accessed by other classes and interfaces that are defined within the same package.

90. Does a class inherit the constructors of its superclass?

A class does not inherit constructors from any of its superclasses.

91. Name the eight primitive Java types.

117 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 118: General technical interview questions

The eight primitive types are byte, char, short, int, long, float, double, and boolean.

92. What restrictions are placed on the values of each case of a switch statement?

During compilation, the values of each case of a switch statement must evaluate to a value that can be promoted to an int value.

93. What is the difference between a while statement and a do while statement?

A while statement checks at the beginning of a loop to see whether the next loop iteration should occur. A do while statement checks at the end of a loop to see whether the next iteration of a loop should occur. The do whilestatement will always execute the body of a loop at least once.

94. What modifiers can be used with a local inner class?

A local inner class may be final or abstract.

95. When does the compiler supply a default constructor for a class?

The compiler supplies a default constructor for a class if no other constructors are provided.

96. If a method is declared as protected, where may the method be accessed?

A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.

97. What are the legal operands of the instanceof operator?

The left operand is an object reference or null value and the right operand is a class, interface, or array type.

98. Are true and false keywords?

The values true and false are not keywords.

99. What happens when you add a double value to a String?

The result is a String object.

100. What is the diffrence between inner class and nested class?

When a class is defined within a scope od another class, then it becomes inner class. If the access modifier of the inner class is static, then it becomes nested class.

101. Can an abstract class be final?

An abstract class may not be declared as final.

102. What is numeric promotion?

118 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 119: General technical interview questions

Numeric promotion is the conversion of a smaller numeric type to a larger numeric type, so that integer and floating-point operations may take place. In numerical promotion, byte, char, and short values are converted to int values. The int values are also converted to long values, if necessary. The long and float values are converted to double values, as required.

103. What is the difference between a public and a non-public class?

A public class may be accessed outside of its package. A non-public class may not be accessed outside of its package.

104. To what value is a variable of the boolean type automatically initialized?

The default value of the boolean type is false.

105. What is the difference between the prefix and postfix forms of the ++ operator?

The prefix form performs the increment operation and returns the value of the increment operation. The postfix form returns the current value all of the expression and then performs the increment operation on that value.

106. What restrictions are placed on method overriding?

Overridden methods must have the same name, argument list, and return type. The overriding method may not limit the access of the method it overrides. The overriding method may not throw any exceptions that may not be thrown by the overridden method.

107. What is a Java package and how is it used?

A Java package is a naming context for classes and interfaces. A package is used to create a separate name space for groups of classes and interfaces. Packages are also used to organize related classes and interfaces into a single API unit and to control accessibility to these classes and interfaces.

108. What modifiers may be used with a top-level class?

A top-level class may be public, abstract, or final.

109. What is the difference between an if statement and a switch statement?

The if statement is used to select among two alternatives. It uses a boolean expression to decide which alternative should be executed. The switch statement is used to select among multiple alternatives. It uses an int expression to determine which alternative should be executed.

110. What are the practical benefits, if any, of importing a specific class rather than an entire package (e.g. import java.net.* versus import java.net.Socket)?

It makes no difference in the generated class files since only the classes that are actually used are referenced by the generated class file. There is another practical benefit to importing single classes, and this arises when two (or more) packages have classes with the same name. Take java.util.Timer and javax.swing.Timer, for example. If I import java.util.* and javax.swing.* and then try to use "Timer", I get an error while compiling (the class

119 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 120: General technical interview questions

name is ambiguous between both packages). Let's say what you really wanted was thejavax.swing.Timer class, and the only classes you plan on using in java.util are Collection and HashMap. In this case, some people will prefer to import java.util.Collection and import java.util.HashMapinstead of importing java.util.*. This will now allow them to use Timer, Collection, HashMap, and otherjavax.swing classes without using fully qualified class names in.

111. Can a method be overloaded based on different return type but same argument type ?

No, because the methods can be called without using their return type in which case there is ambiquity for the compiler.

112. What happens to a static variable that is defined within a method of a class ?

Can't do it. You'll get a compilation error.

113. How many static initializers can you have ?

As many as you want, but the static initializers and class variable initializers are executed in textual order and may not refer to class variables declared in the class whose declarations appear textually after the use, even though these class variables are in scope.

114. What is the difference between method overriding and overloading?

Overriding is a method with the same name and arguments as in a parent, whereas overloading is the same method name but different arguments

115. What is constructor chaining and how is it achieved in Java ?

A child object constructor always first needs to construct its parent (which in turn calls its parent constructor.). In Java it is done via an implicit call to the no-args constructor as the first statement.

116. What is the difference between the Boolean & operator and the && operator?

If an expression involving the Boolean & operator is evaluated, both operands are evaluated. Then the & operator is applied to the operand. When an expression involving the && operator is evaluated, the first operand is evaluated. If the first operand returns a value of true then the second operand is evaluated. The && operator is then applied to the first and second operands. If the first operand evaluates to false, the evaluation of the second operand is skipped.

117. Which Java operator is right associative?

The = operator is right associative.

118. Can a double value be cast to a byte?

Yes, a double value can be cast to a byte.

119. What is the difference between a break statement and a continue statement?

120 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 121: General technical interview questions

A break statement results in the termination of the statement to which it applies (switch, for, do, or while). Acontinue statement is used to end the current loop iteration and return control to the loop statement.

120. Can a for statement loop indefinitely?

Yes, a for statement can loop indefinitely. For example, consider the following: for(;;);

121. To what value is a variable of the String type automatically initialized?

The default value of an String type is null.

122. What is the difference between a field variable and a local variable?

A field variable is a variable that is declared as a member of a class. A local variable is a variable that is declared local to a method.

123. How are this() and super() used with constructors?

this() is used to invoke a constructor of the same class. super() is used to invoke a superclass constructor.

124. What does it mean that a class or member is final?

A final class cannot be inherited. A final method cannot be overridden in a subclass. A final field cannot be changed after it's initialized, and it must include an initializer statement where it's declared.

125. What does it mean that a method or class is abstract?

An abstract class cannot be instantiated. Abstract methods may only be included in abstract classes. However, an abstract class is not required to have any abstract methods, though most of them do. Each subclass of an abstract class must override the abstract methods of its superclasses or it also should be declared abstract.

126. What is a transient variable?

Transient variable is a variable that may not be serialized.

127. How does Java handle integer overflows and underflows?

It uses those low order bytes of the result that can fit into the size of the type allowed by the operation.

128. What is the difference between the >> and >>> operators?

The >> operator carries the sign bit when shifting right. The >>> zero-fills bits that have been shifted out.

129. Is sizeof a keyword?

121 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 122: General technical interview questions

The sizeof operator is not a keyword.

Basic Core Java Interview Questions

1.           What are Web Services?

Web services are business logic components which provide functionality via. Internet using

standard protocols such as HTTP. It is created using Soap or Rest. For E.g. in google search page

we got results like feeds, advertisement , news etc.,   from multiple sites, it is by web services

which enables various websites to talk to each other and share data between them.

2.           Differences between Soap vs. Rest.

SOAP - "Simple Object Access Protocol"

        SOAP is a method of transferring messages, or small amounts of information, over the Internet.

SOAP messages are formatted in XML and are typically sent using HTTP (hypertext transfer

protocol).

Rest - Representational state transfer

        Rest is a simple way of sending and receiving data between client and server and it doesn't have

very many standards defined. You can send and receive data as JSON, XML or even plain text. Its

light weighted compared to SOAP.

3.           How to create a DB connection.

Five steps to query a database:

1.   Load the driver

2.   Get connection

3.   Query the database

4.   Process the result set

5.   Close connection

4.           Differences between prepared statement and callable statement.

Prepared Statement – Execute a precompiled SQL with/without input parameters.

Callable Statements – Execute a call to database stored procedure.

5.           Difference between Application server and Web server.

122 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 123: General technical interview questions

Application server Web server

Web server serves HTTP content Application server serves HTTP, RMI/RPC

etc.

Webserver is suitable for static content. Application server supports dynamic

content also.

Webserver does not contain inbuilt web

server component.

Application server contains inbuilt web

server component.

IIS, Jetty, Tomcat, Apache etc... Is webserver SharePoint, JBOSS, EJB, WAS etc… Is

application server.

Webserver does not add any functionality Application server adds functionality

To applications.

6.           Difference between System. Out and System. Err.  

System. Err is a PrintStream. System. Err works like System. Out except it is normally only

used to output error texts. Some programs (like Eclipse) will show the output to System. Err in red

text, to make it more obvious that it is error text.    

7.           Difference between http and https.

         HTTP HTTPS

URL begins with “http://” URL begins with “https://”

It uses port 80 for communication. It uses port 443 for communication

Unsecured Secured

Operates at Application Layer Operates at Transport Layer

No encryption Encryption is present

No certificates required Certificates required

8.           What is Key Store?

Java Key Store (JKS) is a repository of security certificates, either authorization certificates or

public key certificates - used for instance in SSL encryption.

10.        Difference between Static and Non-Static variable/Method.

Static Non-static

Static members are one per class Non-static Variables are 1 per instance.

Static members are accessed by their class

name which encapsulates them

Non-static members are accessed by object

reference.

Static methods can be accessed directly Non-static methods (or instance methods as

123 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 124: General technical interview questions

from the class I like to call them) have to be accessed from

an instance.

static members can't use non-static

methods without instantiating an objet

Non-static members can use static

members directly.

static constructor is used to initialize static

fields

Non-static fields normal instance

constructor is used.

11.        What is immutability in java?

Once created the objects state cannot be changed .E.g. string

12.        How to create read only values in java.

Using final keyword

Final int a=4;

13.        Difference between String and StringBuffer.

String StringBuffer

String is used to manipulate character

strings that cannot be changed (read-only

and immutable).

StringBuffer is used to represent characters

that can be modified.

String is slow when performing

concatenations because concatenating a

string created new object.

StringBuffer is faster when performing

concatenations.

String is immutable StringBuffer is mutable

String is not synchronized StringBuffer is synchronized

14.        Difference between Hashmap and Hashtable.

        Hashtable is synchronized but Hashmap is not.

        Hashtable can't contain null values but Hashmap permits null values.

15.        Difference between Iterator and Enumeration.

        Iterator has remove () method but Enumeration do not have.

        Iterator is used to Add and remove object, enumeration is used to traverse and fetch objects.

        Iterator is used to manipulate text but Enumeration is used for read-only access.

16.        Define Class-object relationship.

Object - Objects have states and behaviors. Example: A dog has states-color, name, and breed

as well as behaviors -wagging, barking, and eating. An object is an instance of a class.

124 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 125: General technical interview questions

Class - A class can be defined as a template/ blue print that describe the behaviors/states that

object of its type support.

Class is a blueprint while objects are actual objects existing in real word.

17.        What  to test while testing Client-server application.

        Performance

        Load

        Integration between multiple components

        MUT

        SOAK testing

        Multiple clients for same server

19.        Difference between Method Overloading and Overriding.

 Method Overloading  Method Overriding

Arguments Must change Arguments  Must not changeReturn type Can change Return type  Can’t change except for

covariant returnsExceptions Can change Exceptions  Can reduce or eliminate. Must

not throw new or broader checked exceptions

Access Can change Access  Must not make more restrictive (can be less restrictive)

Invocation  Reference type determines which overloaded version is selected. Happens at compile time.

Invocation  Object type determines which method is selected. Happens at runtime

21.        Difference between int & INTEGER.

int is a primitive type. Variables of type int store the actual binary value for the integer you

want to represent. int.parseInt("1") doesn't make sense because int is not a class and therefore

doesn't have any methods.

Integer is a class, no different from any other in the Java language. Variables of type Integer

store a reference to Integer objects, just as with any other reference type. Integer.parseInt("1") is

calling the static method parseInt from class Integer (note that this method actually returns an int

and not an Integer).

int type Declaration:

 int count;

        count is a primitive

        count stores 32 bits of information (in the range Integer.MIN_VALUE to Integer.MAX_VALUE)

125 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 126: General technical interview questions

        Literal integers (e.g. 123 or 0x7b) are of type int

Integer type Declaration:

 Integer count2;

        count2 is an object reference

        count2 points to an object of type java.lang.Integer (or to null)

        The object count2 points at has an int member variable as described above.

To be more specific, Integer is a class with a single field of type int. This class is used where

you need an int to be treated like any other object.

22.        Difference between abstract class and interface.

Abstract Class Interfaces

An abstract class can provide complete, default

code and/or just the details that have to be

overridden.

An interface cannot provide any code at all, just the

signature.

In case of abstract class, a class may extend only

one abstract class.A Class may implement several interfaces.

An abstract class can have non-abstract

methods.All methods of an Interface are abstract.

An abstract class can have instance variables. An Interface cannot have instance variables.

An abstract class can have any visibility: public,

private, protected.An Interface visibility must be public (or) none.

If we add a new method to an abstract class then

we have the option of providing default

implementation and therefore all the existing

code might work properly.

If we add a new method to an Interface then we have to

track down all the implementations of the interface and

define implementation for the new method.

An abstract class can contain constructors. An Interface cannot contain constructors.

Abstract classes are fast.Interfaces are slow as it requires extra indirection to find

corresponding method in the actual class.

23.        Difference between Serialization and synchronization.

        Serialization is a process by which object instance is converted into stream of bytes.

        Synchronization ensures that object data is into accessed by multiple threads at the same time.

126 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 127: General technical interview questions

24.        Difference between sleep and wait. Which is better?

        Wait is better than sleep.

        Sleep cannot be waken but Wait can be woken using notify method.

        Sleeps do not release lock but Wait releases lock.

25.        Difference between Array and ArrayList.

        Array size is fixed at the time of declaration. We can’t modify it.

        ArrayList size is not fixed at the time of declaration. We can change its contents.

26.        Difference between Set and Map.

        Set – It is also an interface to represent linear collection with no duplicates. Order of insertion is

not maintained. Example:- Harshest, Tree Set.

        Map – It represents an indexed collection i.e. key-value pairs. Example: - Hashmap.

27.        What is AJAX?

        AJAX stands for Asynchronous JavaScript and XML. AJAX is a new technique for creating better, faster, and more interactive web applications with the help of XML, HTML, CSS and Java Script.

        Ajax uses XHTML for content and CSS for presentation, as well as the Document Object Model and JavaScript for dynamic content display.

        Conventional web application transmit information to and from the sever using synchronous requests. This means you fill out a form, hit submit, and get directed to a new page with new information from the server.

        With AJAX when submit is pressed, JavaScript will make a request to the server, interpret the results and update the current screen. In the purest sense, the user would never know that anything was even transmitted to the server.

        XML is commonly used as the format for receiving server data, although any format, including plain text, can be used.

        AJAX is a web browser technology independent of web server software.        A user can continue to use the application while the client program requests information from

the server in the background        Intuitive and natural user interaction.        No clicking required only Mouse movement is a sufficient event trigger.        Data-driven as opposed to page-driven

29.        What is final modifier?

The final modifier keyword makes that the programmer cannot change the value anymore. The actual meaning depends on whether it is applied to a class, a variable, or a method.

         Final Methods- A final method cannot be overridden by subclasses.         Final Variables- A final variable cannot be changed once it is initialized.         Final Classes- A final class cannot have subclasses.

31.        What is the different between inheritance and interface?

        Inheritance:

In java classes can be derived from classes. Basically if you need to create a new class and

here is already a class that has some of the code you require, then it is possible to derive your new

class from the already existing code. This concept allows you to reuse the fields and methods of

127 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 128: General technical interview questions

the existing class without having to rewrite the code in a new class. In this scenario the existing

class is called the super class and the derived class is called the subclass.

        Interface:

In Java language an interface can be defined as a contract between objects on how to

communicate with each other. Interfaces play a vital role when it comes to the concept of

inheritance. An interface defines the methods, a deriving class (subclass) should use. But the

implementation of the methods is totally up to the subclass.

33.        What are Access Modifiers in Java?

        Default: A variable or method declared without any access control modifier is available to any

other class in the same package

        Public: A class, method, constructor, interface etc. declared public can be accessed from any

other class

        Protected Variables methods and constructors which are declared protected in a superclass can

be accessed only by the subclasses in other package or any class within the package of the

protected members' class

        Private: Methods, Variables and Constructors that are declared private can only be accessed

within the declared class itself.

Non-access Modifiers: final, abstract.

34.        What is the difference between abstraction and encapsulation?

Encapsulation: - it means binding up of data and methods it means the concept of class in

which we put together the data members and methods or function members.

Abstraction: - it means that hiding the background details which are not useful to the user for

it we use normally private or protected access specifier by it data is not let free to move around

the system.

1) Abstraction is implemented in Java using interface and abstract class while Encapsulation is

implemented using private, package-private and protected access modifier.

2) Encapsulation is also called data hiding.

3) Design principles "programming for interface than implementation" is based on abstraction

and "encapsulate whatever changes" is based upon Encapsulation.

35.        What is i18n and L10n?

        I18n stands for Internationalization (18 char between I and n).

        L10n stands for Localization (10 char between l and n.)It is the means by which i18n applications

can be used for local regions.

        What is the difference between Inheritance and Interface?

128 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 129: General technical interview questions

37.        What are the difference between Java and JavaScript?

Java JavaScriptJava is an Object Oriented Programming (OOP) language

JavaScript is a scripting language

Java is very much Complex. JavaScript s comparatively easy.Java contains rich set of commands. JavaScript contains a much smaller and

simpler set of commandsJava can stand on its own that creates "standalone" applications.

JavaScript must (primarily) be placed inside an HTML document to function

Java must be compiled into what is known as a "machine language" before it can be run on the Web.

JavaScript is text-based. You write it to an HTML document and it is run through a browser.

38.        What is the base class of all classes?

java.lang.Object

40.        What is the difference between Checked and Unchecked exceptions?

The compiler forces you to either catch checked exceptions or throw them to the calling

method. For e.g.  IOException.

Unchecked exceptions (Runtime exception) are due to programming bugs (for ex. index out of

bound exception). The compiler expects you to handle this in the code so it does not force you to

catch unchecked exceptions. Exceptions extending Runtime Exception are unchecked.

41.        What is Auto boxing and unboxing.

Auto boxing-Automatic conversion of primitives into corresponding objects wrapper classes.

Unboxing - Automatic conversion of wrapper classes into primitives.

Need

The collections like ArrayList store only the objects so primitives need to converted to object

wrapper classes.

Auto boxing/Unboxing helps to do automatic conversion.

42.        What is the difference between executequery and executeupdate.

        executeQuery method is used to execute SQL which returns ResultSet.

        executeUpdate method is used to execute update queries like insert, update, or delete.

43.        What is Annotation?

An annotation indicates that the declared element should be processed in some special way

by a compiler, development tool, and deployment tool or during runtime.

44.        What is the Difference between put and post?

HTTP PUT:

129 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 130: General technical interview questions

PUT puts a file or resource at a specific URI, and exactly at that URI. If there's already a file or

resource at that URI, PUT replaces that file or resource. If there is no file or resource there, PUT

creates one HTTP 1.1 RFC location for PUT.

HTTP POST:

POST sends data to a specific URI and expects the resource at that URI to handle the request.

The web server at this point can determine what to do with the data in the context of the specified

resource.

45.        What are Java Annotations?

Java 5 comes with several pre built annotations

        Override

        Deprecated

        SupressWarning

        Retention

        Target

46.        Write a program to generate 15 random integers between 0 and 10.

Random r = new Random();

for(int i=0;i<15;i++){

    System.out.println(r.nextInt(10));

}

49.        Difference between Throw and Throws.

        Throws – used to advertise that the method might throw some exceptions.

        Throw – used to throw exception from method definition.

50.        Write a difference between System.exit(0) and System.exit(1).

        System.exit(0) is used in any method to come out of the program. It terminates the program

normally where as

        System.exit(1) terminates the program because of some error encountered in the program.

Java Basics

1. What is the difference between a constructor and a method?

130 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 131: General technical interview questions

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.

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

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.

3. Describe synchronization in respect to multithreading.

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.

4. What is an abstract class?

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.

5. What is the difference between an Interface and an Abstract class?

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.

6. Explain different way of using thread?

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.

7. What is an Iterator?

131 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 132: General technical interview questions

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.

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

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.

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.

9. What is static in java?

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.

10. What is final class?

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

11. What if the main() method is declared as private?

The program compiles properly but at runtime it will give "main() method not public." message.

12. What if the static modifier is removed from the signature of the main() method?

Program compiles. But at runtime throws an error "NoSuchMethodError".

13. What if I write static public void instead of public static void?

132 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 133: General technical interview questions

Program compiles and runs properly.

14. What if I do not provide the String array as the argument to the method?

Program compiles but throws a runtime error "NoSuchMethodError".

15. What is the first argument of the String array in main() method?

The String array is empty. It does not have any element. This is unlike C/C++ where the first element by default is the program name.

16. If I do not provide any arguments on the command line, then the String array of main() method will be empty or null?

It is empty. But not null.

17. How can one prove that the array is not null but empty using one line of code?

Print args.length. It will print 0. That means it is empty. But if it would have been null then it would have thrown a NullPointerException on attempting to print args.length.

18. What environment variables do I need to set on my machine in order to be able to run Java programs?

CLASSPATH and PATH are the two variables.

19. Can an application have multiple classes having main() method?

Yes it is possible. While starting the application we mention the class name to be run. The JVM will look for the Main method only in the class whose name you have mentioned.

Hence there is not conflict amongst the multiple classes having main() method.

20. Can I have multiple main() methods in the same class?

No the program fails to compile. The compiler says that the main() method is already defined in the class.

21. Do I need to import java.lang package any time? Why ?

No. It is by default loaded internally by the JVM.

22. Can I import same package/class twice? Will the JVM load the package twice at runtime?

One can import the same package or same class multiple times. Neither compiler nor JVM complains about it. And the JVM will internally load the class only once no matter how many times you import the same class.

23. What are Checked and UnChecked Exception?

133 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 134: General technical interview questions

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.

Example: 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.

Example: 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.

24. What is Overriding?

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.

25. Are the imports checked for validity at compile time? Example: will the code containing an import such as java.lang.ABCD compile?

Yes the imports are checked for the semantic validity at compile time. The code containing above line of import will not compile. It will throw an error saying, can not resolve symbol

symbol : class ABCD

location: package io

import java.io.ABCD;

26. Does importing a package imports the subpackages as well? Example: Does importing com.MyTest.* also import com.MyTest.UnitTests.*?

No you will have to import the subpackages explicitly. Importing com.MyTest.* will import classes in the package MyTest only. It will not import any class in any of it's subpackage.

27. What is the difference between declaring a variable and defining a variable?

In declaration we just mention the type of the variable and it's name. We do not initialize it. But defining means declaration + initialization.

Example: String s; is just a declaration while String s = new String ("abcd"); Or String s = "abcd"; are both definitions.

28. What is the default value of an object reference declared as an instance variable?

134 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 135: General technical interview questions

The default value will be null unless we define it explicitly.

29. Can a top level class be private or protected?

No. A top level class cannot be private or protected. It can have either "public" or no modifier. If it does not have a modifier it is supposed to have a default access.

If a top level class is declared as private the compiler will complain that the "modifier private is not allowed here". This means that a top level class can not be private. Same is the case with protected.

30. What type of parameter passing does Java support?

In Java the arguments are always passed by value.

31. Primitive data types are passed by reference or pass by value?

Primitive data types are passed by value.

32. Objects are passed by value or by reference?

Java only supports pass by value. With objects, the object reference itself is passed by value and so both the original reference and parameter copy both refer to the same object.

33. What is serialization?

Serialization is a mechanism by which you can save the state of an object by converting it to a byte stream.

34. How do I serialize an object to a file?

The class whose instances are to be serialized should implement an interface Serializable. Then you pass the instance to the ObjectOutputStream which is connected to a fileoutputstream. This will save the object to a file.

35. Which methods of Serializable interface should I implement?

The serializable interface is an empty interface, it does not contain any methods. So we do not implement any methods.

36. How can I customize the seralization process? i.e. how can one have a control over the serialization process?

Yes it is possible to have control over serialization process. The class should implement Externalizable interface. This interface contains two methods namely readExternal and writeExternal.

You should implement these methods and write the logic for customizing the serialization process.

37. What is the common usage of serialization?

135 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 136: General technical interview questions

Whenever an object is to be sent over the network, objects need to be serialized. Moreover if the state of an object is to be saved, objects need to be serilazed.

38. What is Externalizable interface?

Externalizable is an interface which contains two methods readExternal and writeExternal. These methods give you a control over the serialization mechanism.

Thus if your class implements this interface, you can customize the serialization process by implementing these methods.

39. When you serialize an object, what happens to the object references included in the object?

The serialization mechanism generates an object graph for serialization. Thus it determines whether the included object references are serializable or not. This is a recursive process.

Thus when an object is serialized, all the included objects are also serialized alongwith the original obect.

40. What one should take care of while serializing the object?

One should make sure that all the included objects are also serializable. If any of the objects is not serializable then it throws a NotSerializableException.

41. What happens to the static fields of a class during serialization?

There are three exceptions in which serialization doesnot necessarily read and write to the stream. These are

1. Serialization ignores static fields, because they are not part of ay particular state state.

2. Base class fields are only hendled if the base class itself is serializable.

3. Transient fields.

42. Does Java provide any construct to find out the size of an object?

No, there is not sizeof operator in Java. So there is not direct way to determine the size of an object directly in Java.

43. What are wrapper classes?

Java provides specialized classes corresponding to each of the primitive data types. These are called wrapper classes.

They are example: Integer, Character, Double etc.

44. Why do we need wrapper classes?

136 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 137: General technical interview questions

It is sometimes easier to deal with primitives as objects. Moreover most of the collection classes store objects and not primitive data types. And also the wrapper classes provide many utility methods also.

Because of these resons we need wrapper classes. And since we create instances of these classes we can store them in any of the collection classes and pass them around as a collection. Also we can pass them around as method parameters where a method expects an object.

45. What are checked exceptions?

Checked exception are those which the Java compiler forces you to catch.

Example: IOException are checked exceptions.

46. What are runtime exceptions?

Runtime exceptions are those exceptions that are thrown at runtime because of either wrong input data or because of wrong business logic etc. These are not checked by the compiler at compile time.

47. What is the difference between error and an exception?

An error is an irrecoverable condition occurring at runtime. Such as OutOfMemory error.

These JVM errors and you can not repair them at runtime. While exceptions are conditions that occur because of bad input etc. Example: FileNotFoundException will be thrown if the specified file does not exist. Or aNullPointerException will take place if you try using a null reference.

In most of the cases it is possible to recover from an exception (probably by giving user a feedback for entering proper values etc.).

48. How to create custom exceptions?

Your class should extend class Exception, or some more specific type thereof.

49. If I want an object of my class to be thrown as an exception object, what should I do?

The class should extend from Exception class. Or you can extend your class from some more precise exception type also.

50. If my class already extends from some other class what should I do if I want an instance of my class to be thrown as an exception object?

One can not do anytihng in this scenarion. Because Java does not allow multiple inheritance and does not provide any exception interface as well.

51. How does an exception permeate through the code?

An unhandled exception moves up the method stack in search of a matching When an exception is thrown from a code which is wrapped in a try block followed by one or more catch blocks, a search

137 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 138: General technical interview questions

is made for matching catch block. If a matching type is found then that block will be invoked. If a matching type is not found then the exception moves up the method stack and reaches the caller method.

Same procedure is repeated if the caller method is included in a try catch block. This process continues until a catch block handling the appropriate type of exception is found. If it does not find such a block then finally the program terminates.

52. What are the different ways to handle exceptions?

There are two ways to handle exceptions,

1. By wrapping the desired code in a try block followed by a catch block to catch the exceptions. and

2. List the desired exceptions in the throws clause of the method and let the caller of the method hadle those exceptions.

53. Is it necessary that each try block must be followed by a catch block?

It is not necessary that each try block must be followed by a catch block. It should be followed by either a catch block or a finally block. And whatever exceptions are likely to be thrown should be declared in the throws clause of the method.

54. If I write return at the end of the try block, will the finally block still execute?

Yes even if you write return as the last statement in the try block and no exception occurs, the finally block will execute. The finally block will execute and then the control return.

55. If I write System.exit(0); at the end of the try block, will the finally block still execute?

No. In this case the finally block will not execute because when you say System.exit(0); the control immediately goes out of the program, and thus finally never executes.

56. How are Observer and Observable used?

Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects.

57. What is synchronization and why is it important?

With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources.

Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object's value. This often leads to significant errors.

138 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 139: General technical interview questions

58. How does Java handle integer overflows and underflows?

It uses those low order bytes of the result that can fit into the size of the type allowed by the operation.

59. Does garbage collection guarantee that a program will not run out of memory?

Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.

60. What is the difference between preemptive scheduling and time slicing?

Under preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence.

Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks. The scheduler then determines which task should execute next, based on priority and other factors.

61. When a thread is created and started, what is its initial state?

A thread is in the ready state after it has been created and started.

62. What is the purpose of finalization?

The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.

63. What is the Locale class?

The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region.

64. What is the difference between a while statement and a do statement?

A while statement checks at the beginning of a loop to see whether the next loop iteration should occur.

A do statement checks at the end of a loop to see whether the next iteration of a loop should occur. The do statement will always execute the body of a loop at least once.

65. What is the difference between static and non-static variables?

A static variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on unique values with each object instance.

66. How are this() and super() used with constructors?

this() is used to invoke a constructor of the same class. super() is used to invoke a superclass constructor.

139 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 140: General technical interview questions

67. What is daemon thread and which method is used to create the daemon thread?

Daemon thread is a low priority thread which runs intermittently in the back ground doing the garbage collection operation for the java runtime system.setDaemon method is used to create a daemon thread.

68. Can applets communicate with each other?

At this point in time applets may communicate with other applets running in the same virtual machine. If the applets are of the same class, they can communicate via shared static variables. If the applets are of different classes, then each will need a reference to the same class with static variables. In any case the basic idea is to pass the information back and forth through a static variable.

An applet can also get references to all other applets on the same page using the getApplets() method ofjava.applet.AppletContext. Once you get the reference to an applet, you can communicate with it by using its public members.

It is conceivable to have applets in different virtual machines that talk to a server somewhere on the Internet and store any data that needs to be serialized there. Then, when another applet needs this data, it could connect to this same server. Implementing this is non-trivial.

69. What are the steps in the JDBC connection?

While making a JDBC connection we go through the following steps :

Step 1 : Register the database driver by using :

Class.forName(\" driver classs for that specific database\" );

Step 2 : Now create a database connection using :

Connection con = DriverManager.getConnection(url,username,password);

Step 3: Now Create a query using :

Statement stmt = Connection.Statement(\"select * from TABLE NAME\");

Step 4 : Exceute the query :

stmt.exceuteUpdate();

70. How does a try statement determine which catch clause should be used to handle an exception?

When an exception is thrown within the body of a try statement, the catch clauses of the try statement are examined in the order in which they appear. The first catch clause that is capable of handling the exceptionis executed. The remaining catch clauses are ignored.

71. Can an unreachable object become reachable again?

140 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 141: General technical interview questions

An unreachable object may become reachable again. This can happen when the object's finalize() method is invoked and the object performs an operation which causes it to become accessible to reachable objects.

72. What method must be implemented by all threads?

All tasks must implement the run() method, whether they are a subclass of Thread or implement the Runnable interface.

73. What are synchronized methods and synchronized statements?

Synchronized methods are methods that are used to control access to an object. A thread only executes a synchronized method after it has acquired the lock for the method's object or class.

Synchronized statements are similar to synchronized methods. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.

74. What is Externalizable?

Externalizable is an Interface that extends Serializable Interface. And sends data into Streams in Compressed Format. It has two methods, writeExternal(ObjectOuput out) and readExternal(ObjectInput in).

75. What modifiers are allowed for methods in an Interface?

Only public and abstract modifiers are allowed for methods in interfaces.

76. What are some alternatives to inheritance?

Delegation is an alternative to inheritance.

Delegation means that you include an instance of another class as an instance variable, and forward messages to the instance. It is often safer than inheritance because it forces you to think about each message you forward, because the instance is of a known class, rather than a new class, and because it doesn't force you to accept all the methods of the super class: you can provide only the methods that really make sense. On the other hand, it makes you write more code, and it is harder to re-use (because it is not a subclass).

77. What does it mean that a method or field is "static"?

Static variables and methods are instantiated only once per class. In other words they are class variables, not instance variables. If you change the value of a static variable in a particular object, the value of that variable changes for all instances of that class.

Static methods can be referenced with the name of the class rather than the name of a particular object of the class (though that works too). That's how library methods like System.out.println() work out is a static field in the java.lang.System class.

78. What is the difference between preemptive scheduling and time slicing?

141 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 142: General technical interview questions

Under preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence. Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks.

The scheduler then determines which task should execute next, based on priority and other factors.

79. What is the catch or declare rule for method declarations?

If a checked exception may be thrown within the body of a method, the method must either catch the exception or declare it in its throws clause.

80. Is Empty .java file a valid source file?

Yes. An empty .java file is a perfectly valid source file.

81. Can a .java file contain more than one java classes?

Yes. A .java file contain more than one java classes, provided at the most one of them is a public class.

82. Is String a primitive data type in Java?

No. String is not a primitive data type in Java, even though it is one of the most extensively used object. Strings in Java are instances of String class defined in java.lang package.

83. Is main a keyword in Java?

No. main is not a keyword in Java.

84. Is next a keyword in Java?

No. next is not a keyword.

85. Is delete a keyword in Java?

No. delete is not a keyword in Java. Java does not make use of explicit destructors the way C++ does.

86. Is exit a keyword in Java?

No. To exit a program explicitly you use exit method in System object.

87. What happens if you dont initialize an instance variable of any of the primitive types in Java?

Java by default initializes it to the default value for that primitive type. Thus an int will be initialized to 0(zero), a boolean will be initialized to false.

88. What will be the initial value of an object reference which is defined as an instance variable?

142 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 143: General technical interview questions

The object references are all initialized to null in Java. However in order to do anything useful with these references, you must set them to a valid object, else you will get NullPointerExceptions everywhere you try to use such default initialized references.

89. What are the different scopes for Java variables?

The scope of a Java variable is determined by the context in which the variable is declared. Thus a java variable can have one of the three scopes at any given point in time.

1. Instance : - These are typical object level variables, they are initialized to default values at the time of creation of object, and remain accessible as long as the object accessible.

2. Local : - These are the variables that are defined within a method. They remain accessbile only during the course of method excecution. When the method finishes execution, these variables fall out of scope.

3. Static: - These are the class level variables. They are initialized when the class is loaded in JVM for the first time and remain there as long as the class remains loaded. They are not tied to any particular object instance.

90. What is the default value of the local variables?

The local variables are not initialized to any default value, neither primitives nor object references. If you try to use these variables without initializing them explicitly, the java compiler will not compile the code. It will complain abt the local varaible not being initilized.

91. How many objects are created in the following piece of code?MyClass c1, c2, c3;c1 = new MyClass ();c3 = new MyClass ();

Only 2 objects are created, c1 and c3. The reference c2 is only declared and not initialized.

92. Can a public class MyClass be defined in a source file named YourClass.java?

No. The source file name, if it contains a public class, must be the same as the public class name itself with a.java extension.

93. Can main() method be declared final?

Yes, the main() method can be declared final, in addition to being public static.

94. What is HashMap and Map?

Map is an Interface and Hashmap is the class that implements Map.

95. Difference between HashMap and HashTable?

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

143 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 144: General technical interview questions

HashMap does not guarantee that the order of the map will remain constant over time. HashMap is unsynchronized and Hashtable is synchronized.

96. Difference between Vector and ArrayList?

Vector is synchronized whereas arraylist is not.

97. Difference between Swing and Awt?

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

98. What will be the default values of all the elements of an array defined as an instance variable?

If the array is an array of primitive types, then all the elements of the array will be initialized to the default value corresponding to that primitive type.

Example: All the elements of an array of int will be initialized to 0(zero), while that of boolean type will be initialized to false. Whereas if the array is an array of references (of any type), all the elements will be initialized to null.

Selenium Questions

Well, this doc is not going to help you crack that interview but I know there are many interviewer out there who want to know answer of one liner Selenium interview questions.

Generic Selenium Questions

Question 1:

What is Selenium?

Answer:

Selenium is a browser automation tool which lets you automated operations like – type, click, and selection from a drop down of a web page.

Question 2:

How is Selenium different from commercial browser automation tools?

Answer:

Selenium is a library which is available in a gamut of languages i.e. java, C#, python, ruby, php etc while most commercial tools are limited in their capabilities of being able to use just one language. More over many of those tools have their own proprietary language which is of little use outside the domain of those tools. Most commercial tools focus on record and replay while Selenium emphasis on using Selenium IDE (Selenium record and replay) tool only to get acquainted with

144 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 145: General technical interview questions

Selenium working and then move on to more mature Selenium libraries like Remote control (Selenium 1.0) and Web Driver (Selenium 2.0).

Though most commercial tools have built in capabilities of test reporting, error recovery mechanisms and Selenium does not provide any such features by default. But given the rich set of languages available with Selenium it very easy to emulate such features.

Question3:

What are the set of tools available with Selenium?

Answer:

Selenium has four set of tools – Selenium IDE, Selenium 1.0 (Selenium RC), Selenium 2.0 (WebDriver) and Selenium Grid. Selenium Core is another tool but since it is available as part of Selenium IDE as well as Selenium 1.0, it is not used in isolation.

Question 4:

Which Selenium Tool should I use?

Answer:

It entirely boils down to where you stand today in terms of using Selenium. If you are entirely new to Selenium then you should begin with Selenium IDE to learn Selenium location strategies and then move to Selenium 2 as it is the most stable Selenium library and future of Selenium. Use Selenium Grid when you want to distribute your test across multiple devices. If you are already using Selenium 1.0 than you should begin to migrate your test scripts to Selenium 2.0

Question 5:

What is Selenium IDE?

Answer:

Selenium IDE is a firefox plug-in which is (by and large) used to record and replay test is firefox browser. Selenium IDE can be used only with firefox browser.

Question 6:

Which language is used in Selenium IDE?

Answer:

Selenium IDE uses html sort of language called Selenese. Though other languages (java, c#, php etc) cannot be used with Selenium IDE, Selenium IDE lets you convert test in these languages so that they could be used with Selenium 1.0 or Selenium 2.0

Question 7:

What is Selenium 1.0?

Answer:

Selenium 1.0 or Selenium Remote Control (popularly known as Selenium RC) is library available in wide variety of languages. The primary reason of advent of Selenium RC was incapability of

145 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 146: General technical interview questions

Selenium IDE to execute tests in browser other than Selenium IDE and the programmatical limitations of language Selenese used in Selenium IDE.

Question 8:

What is Selenium 2.0?

Answer:

Selenium 2.0 also known as WebDriver is the latest offering of Selenium. It provides

better API than Selenium 1.0 does not suffer from java script security restriction which Selenium 1.0 does supports more UI complicated UI operations like drag and drop

Question 9:

What are the element locators available with Selenium which could be used to locate elements on web page?

Answer:

There are mainly 4 locators used with Selenium –

html id html name XPath locator and Css locators

Question 10:

What is Selenium Grid?

Answer:

Selenium grid lets you distribute your tests on multiple machines and all of them at the same time. Hence you can execute test on IE on Windows and Safari on Mac machine using the same test script (well, almost always). This greatly helps in reducing the time of test execution and provides quick feedback to stack holders.

Selenium IDE Questions

Question 11:

What are two modes of views in Selenium IDE?

Answer:

Selenium IDE can be opened either in side bar (View > Side bar > Selenium IDE) or as a pop up window (Tools > Selenium IDE). While using Selenium IDE in browser side bar it cannot record user operations in a pop up window opened by application.

Question 12:

Can I control the speed and pause test execution in Selenium IDE?

146 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 147: General technical interview questions

Answer:

Selenium IDE provides a slider with Slow and Fast pointers to control the speed of execution.

Question 13:

Where do I see the results of Test Execution in Selenium IDE?

Answer:

Result of test execution can be views in log window in Selenium IDE –

Question 14:

Where do I see the description of commands used in Selenium IDE?

Answer:

Commands of description can be seen in Reference section –

Question 15:

Can I build test suite using Selenium IDE?

Answer:

Yes, you can first record individual test cases and then group all of them in a test suite. Following this entire test suite could be executed instead of executing individual tests.

Question 16:

What verification points are available with Selenium?

Answer:

There are largely three type of verification points available with Selenium –

Check for page title Check for certain text Check for certain element (text box, drop down, table etc)

Question 17:

I see two types of check with Selenium – verification and assertion, what’s the difference between tow?

Answer:

A verification check lets test execution continue even in the wake of failure with check, while assertion stops the test execution. Consider an example of checking text on page, you may like to use verification point and let test execution continue even if text is not present. But for a

147 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 148: General technical interview questions

login page, you would like to add assertion for presence of text box login as it does not make sense continuing with test execution if login text box is not present.

Question 18:

I don’t see check points added to my tests while using Selenium IDE, how do I get them added to my tests?

Answer:

You need to use context menu to add check points to your Selenium IDE tests –

Question 19:

How do I edit tests in Selenium IDE?

Answer:

There are two ways to edit tests in Selenium IDE; one is the table view while other looking into the source code of recorded commands –

 Question 20:

What is syntax of command used in Selenium?

Answer:

There are three entities associated with a command –

Name of Command Element Locator (also known as Target) Value (required when using echo, wait etc)

Question 21:

There are tons of Selenium Command, am I going to use all of them

Answer:

This entirely boils down to operations you are carrying out with Selenium. Though you would definitely be using following Selenium Commands more often –

Open: opens a web page. click/clickAndWait: click on an element and waits for a new page to load. Select: Selects a value from a drop down value. verifyTitle/assertTitle: verifies/asserts page title. verify/assert ElementPresent: verifies/asserts presence of element, in the page. verify/assert TextPresent verifies/asserts  expected text is somewhere on the page.

Question 22:

How do I use html id and name while using Selenium IDE

Answer:

148 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 149: General technical interview questions

Html id and name can be used as it is in selenium IDE. For example Google search box has name – “q” and id – “list-b” and they can be used as target in selenium IDE –

Question 23:

What is XPath? When would I have to use XPath in Selenium IDE?

Answer:

XPath is a way to navigate in xml document and this can be used to identify elements in a web page. You may have to use XPath when there is no name/id associated with element on page or only partial part of name/ide is constant.

Direct child is denoted with - /

Relative child is denoted with - //

Id, class, names can also be used with XPath –

//input[@name=’q’] //input[@id=’lst-ib’] //input[@class=’ lst’]

If only part of id/name/class is constant than “contains” can be used as –

//input[contains(@id,'lst-ib')]

Question 24:

What is CSS location strategy in Selenium?

Answer:

CSS location strategy can be used with Selenium to locate elements, it works using cascade style sheet location methods in which -

Direct child is denoted with – (a space)

Relative child is denoted with - >

Id, class, names can also be used with XPath –

css=input[name=’q’] css=input[id=’lst-ib’] or input#lst-ib css=input[class=’ lst’] or input.lst

If only part of id/name/class is constant than “contains” can be used as –

css=input[id*=' lst-ib ')]

Element location strategy using inner text

css = a:contains(‘log out’)

149 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 150: General technical interview questions

Question 25:

There is id, name, XPath, CSS locator, which one should I use?

Answer:

If there are constant name/id available than they should be used instead of XPath and CSS locators. If not then css locators should be given preference as their evaluation is faster than XPath in most modern browsers.Question 26:

 I want to generate random numbers, dates as my test data, how do I do this in Selenium IDE?

Answer:

This can be achieved by executing java script in Selenium. Java script can be executed using following syntax –

            type

            css=input#s

            javascript{Math.random()}

And for date –

            type

            css=input#s

            javascript{new Date()}

Question 27:

Can I store result of an evaluation and use it later in my test?

Answer:

You can use “store” command to achieve this. You can save result of an evaluation in a variable and use it later in your Selenium IDE script. For example we can store value from a text box as following, and later use it to type it in another text box –

            storeText

            css=input#s

            var1

            type

            css=input#d

            ${var1}

150 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 151: General technical interview questions

Question 28:

I have stored result of an evaluation; can I print it in IDE to check its value?

Answer:

You can use echo command as following to check the stored value in Selenium IDE –

            storeText

            css=input#s

            var1

            echo

            ${var1}

           

Question 29:

Can I handle java script alert using Selenium?

Answer

You could use verify/assertAlert to check presence of alert on page. Since selenium cannot click on “Ok” button on js alert window, the alert itself does not appear on page when this check is carried out.

Question 30:

Selenium has recorded my test using XPath, how do I change them to css locator?

Answer

You can use drop down available next to Find in Selenium to change element locator used by Selenium –

Question 31:

I have written my own element locator, how do I test it?

Answer

You can use Find button of Selenium IDE to test your locator. Once you click on it, you would see element being highlighted on screen provided your element locator is right Else one error message would be displayed in log window.

Question 32:

I have written one js extension; can I plug it in Selenium and use it?

Answer

151 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 152: General technical interview questions

You could specify you js extension in “Options” window of Selenium IDE –

Question 33:

How do I convert my Selenium IDE tests from Selenese to another language?

Answer

You could use Format option of Selenium IDE to convert tests in another programming language –

Question 34:

I have converted my Selenium IDE tests to java but I am not able to execute them, execution options as well as Table tab of Selenium IDE is disabled

Answer

This is because Selenium IDE does not support execution of test in any other language than Selenese (language of Selenium IDE). You can convert Selenium IDE in a language of your choice and then use Selenium 1.0 to execute these tests in that language.

Question 35:

I want to use only Selenese as my test script language but still want to execute tests in other browsers, how do I do that?

Answer

You can execute you Selenese test in another browser by specifying the “-htmlSuite” followed by path of your Selenese suite while starting the Selenium Server. Selenium Server would be covered in details in question about Selenium RC.

Question 36:

I have added one command in middle of list of commands, how do I test only this new command?

Answer

You can double click on newly added command and Selenium IDE would execute only that command in browser.

Question 37:

Can I make Selenium IDE tests begin test execution from a certain command and not from the very first command?

Answer

You could set a command as “start” command from context menu. When a command is set as start command then a small green symbol appears before command. Same context menu can be used to toggle this optio

Question 38:

Are there other tools available outside Selenium IDE to help me tests my element locators

Answer

You could XPath checker - https://addons.mozilla.org/en-US/firefox/addon/xpath-checker/  to test you XPath locators and Firefinder (a firebug add on) to test you css locators –

152 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 153: General technical interview questions

https://addons.mozilla.org/en-US/firefox/addon/firefinder-for-firebug/

Firefinder can also be used to test XPath locators.

Question 39:

What is upcoming advancement in Selenium IDE?

Answer

The latest advancement in Selenium IDE would be to have capabilities of converting Selenium IDE tests in Webdriver (Selenium 2.0) options. This would help generating quick and dirty tests for Selenium 2.0

Question 40:

How can I use looping option (flow control) is Selenium IDE

Answer

Selenese does not provide support for looping, but there is extension which could be used to achieve same. This extension can be download from here - http://51elliot.blogspot.com/2008/02/selenium-ide-goto.html

This extension can be added under “Selenium IDE Extension” section to use loop feature in Selenium IDE.

Question 41:

Can I use screen coordinate while using click command? I want to click at specific part of my element.

Answer

You would need to use clickAT command to achieve. clickAt command accepts element locator and x, y coordinates as arguments –

clickAt(locator, coordString)

Question 42:

How do I verify presence of drop down options using Selenium?

Answer

Use assertSelectOptions as following to check options in a drop down list –

assertSelectOptions

Question 43:

Can I get data from a specific html table cell using Selenium IDE?

Answer

Use storeTable command to get data from a specific cell in an html table, following example store text from cell 0,4 from an html table –

153 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 154: General technical interview questions

            storeTable

            css=#tableId.0.4

            textFromCell

Question 44:

I want to make Selenium IDE record and display css locator followed by other locators, is it possible to give high priority to css locator in Selenium IDE?

Answer

You can change default behavior of Selenium IDE > element locator preference by crating js file with following–

LocatorBuilders.order = ['css:name', 'css:id', 'id', 'link', 'name', 'xpath:attributes'];

And add this file under “Selenium IDE Extension” under Selenium Options.

Question 45:

My application has dynamic alerts which don’t always appear, how do I handle them?

Answer

If you want to simulate clicking “ok “ on alert than use – chooseOkOnNextConfirmation and if you want to simulate clicking “cancel” on alert than use - chooseCancelOnNextConfirmation ( )

Question 46:

Can I right click on a locator?

Answer

You can use command - contextMenu ( locator) to simulate right click on an element in web page.

Question 47:

How do I capture screen shot of page using Selenium IDE?

Answer

Use command – captureEntirePageScreenshot to take screen shot of page.

Question 48:

I want to pause my test execution after certain command.

Answer

Use pause command which takes time in milliseconds and would pause test execution for specified time – pause ( waitTime )

Question 49:

154 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 155: General technical interview questions

I used open command to launch my page, but I encountered time out error

Answer

This happens because open commands waits for only 30 seconds for page to load. If you application takes more than 30 sec then you can use “setTimeout ( timeout )” to make selenium IDE wait for specified time, before proceeding with test execution.

Question 50:

What’s the difference between type and typeKeys commands?

Answer

type command simulates enter operations at one go while typeKeys simulates keystroke key by key.

typeKeys could be used when typing data in text box which bring options (like Google suggestion list) because such operation are not usually simulated using type command.

  Selenium RC (Selenium 1.0) Questions

Question 51:

What is Selenium RC (also known as Selenium 1.0)?

Answer

Selenium RC is an offering from SeleniumHQ which tries to overcome following draw backs of Selenium IDE –

Able to execute tests only with Firefox Not able to use full-fledged programming language and being limited to Selenese

Question 52:

What are the main components of Selenium RC?

Answer

Selenium RC has two primary components –

Client libraries which let you writes tests in language of your preference i.e. java, C#, perl, php etc

Selenium sever which acts as a proxy between browser and application under test (aut)

Question 53:

Why do I need Selenium Server?

Answer

Selenium uses java script to drives tests on a browser; Selenium injects its own js to the response which is returned from aut. But there is a java script security restriction (same origin policy)

155 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 156: General technical interview questions

which lets you modify html of page using js only if js also originates from the same domain as html. This security restriction is of utmost important but spoils the working of Selenium. This is where Selenium server comes to play an important role.

Selenium server stands between aut and browser and injects selenium js to the response received from aut and then it is delivered to broswer. Hence browser believes that entire response was delivered from aut.

Question 54:

What is Selenium core? I have never used it!!!

Answer

Selenium core is the core js engine of Selenium which executes tests on browser, but because of same origin policy it needs to be deployed on app server itself, which is not always feasible. Hence Selenium core is not used in isolation. Selenium IDE as well as Selenium RC use Selenium core to drive tests while over coming same origin policy. In case of Selenium IDE tests are run in context of browser hence it is not hindered by same origin policy and with Selenium RC, Selenium Server over comes same origin policy.

Question 55:

Where is executable for Selenium RC, how do I install it?

Answer

Installation is a misnomer for Selenium RC. You don’t install Selenium RC you only add client libraries to you project. For example in case of java you add client driver and Selenium server jars in Eclipse or IntelliJ which are java editors.

Question 56:

I have downloaded Selenium Server and Client libraries, how do I start Selenium Server?

Answer

To start Selenium Server, you need to navigate to installation directory of Selenium server and execute following command –

            Java -jar .jar

This will start Selenium server at port 4444 by default.

Notice that you need to have java version 1.5 or higher available on your system to be able to use Selenium server.

Question 57:

On my machine port 4444 is not free . How do Use another port?

Answer

You can specify port while running the selenium server as –

156 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 157: General technical interview questions

                        Java -jar .jar –port 5555

Question 58:

I am new to programming; can Selenium generate sample code from my Selenese scripts?

Answer

You can first record tests in Selenium IDE and then use format option to convert them in a language of your choice.

Question 59:

Can I start Selenium server from my program instead of command line

Answer

If you are using java then you can start Selenium server using SeleniumServer class. For this you need to instantiate SeleniumServer and then call start() method on it.

            seleniumServer = new SeleniumServer();

     seleniumServer.start();

Question 60:

And how do I start the browser?

Answer

While using java you need to create instance of DefaultSelenium class and pass it four parameters –

selenium = new DefaultSelenium(serverHost, serverPort, browser, appURL);

          selenium.start();

Herein you need to pass,

host where Selenium server is running,

port of Selenium server,

browser where tests are to be executed and

application URL

Question 61:

I am not using java to program my tests, do I still have to install java on my system?

Answer

Yes, since Selenium server is written in java you need java to be installed on your system to be able to use it. Even though you might not be using java to program your tests.

Question 62:

What are the browsers offering from Selenium?

157 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 158: General technical interview questions

Answer

Following browsers could be used with Selenium –

  *firefox

  *firefoxproxy

  *pifirefox

  *chrome

  *iexploreproxy

  *iexplore

  *firefox3

  *safariproxy

  *googlechrome

  *konqueror

  *firefox2

  *safari

  *piiexplore

  *firefoxchrome

  *opera

  *iehta

  *custom

Here pi and proxy stand for proxy injection mode of Selenium server

Question 63:

During execution of tests I see two browser windows; one my test application another window shows commands being executed. Can I limit it to just one window?

Answer

Yes you can instruct Selenium Server to launch just one window. To do so you must specify –singleWindow while starting the Selenium server as –

            Java -jar .jar –singleWindow

Question 64:

My tests usually time out. Can I specify bigger time out?

Answer

This usually happens while using open method with Selenium. One way to overcome this is to use setTimeOut method in your test script another way is to specify time out while starting Selenium server as following –

158 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 159: General technical interview questions

            Java -jar .jar –timeout

Question 65:

My system is behind corporate network, how do I specify my corporate proxy?

Answer

You can specify your corporate proxy as following while starting Selenium Server –

java -jar .jar -Dhttp.proxyHost= -Dhttp.proxyPort= -Dhttp.proxyUser= -Dhttp.proxyPassword=

Question 66:

I am switching domains in my test scripts. I move from “yahoo.com” to “google.com” and my tests encounter permission denied error

Answer

Changing domains is also a security restriction from java script. To overcome this you should start you Selenium server in proxy injection mode as –

java -jar .jar –proxyInjectionMode

Now Selenium server would act as proxy server for all the content going to test application

Question 67:

Can I execute my Selenese tests in another browser using Selenium server? I want to use only Selenese script my tests but still want to execute my test in non firefox browsers

Answer

Yes you can. To do so you need to specify following parameters while starting Selenium server –

            Browser

            Test domain

Path to html suite (you Selenese tests) and

Path to result

java -jar <>.jar -htmlSuite   Question 68:Can I log more options during test execution?

Answer

If you want to log browser side option during test execution then you should start Selenium server as following –  

java -jar <>.jar –browserSideLog

Question 69:

Can I use Selenium RC on my UNIX/Mac also?

Answer

159 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 160: General technical interview questions

You can use Selenium RC on any system which is capable I running Java. Hence you can use it on RC and UNIX machines also

Question 70:

I want to test my scripts on new experimental browser, how do I do that?

Answer

You can specify *custom followed by path to browser to execute your tests on any browser while starting Selenium server

         *custom   Question 71:

I executed my tests cases but where is the test report?

Answer

Selenium RC itself does not provide any mechanism for test reporting. Test reporting is driven from the framework you use for Selenium. For example with java client driver of Selenium –

if you are using JUnit then you can use ant plug-in of JUnit to generate test report if you are using TestNG then TestNG generates reports for you

Same reporting option is available with PHP unit and other client libraries you are using.

Question 72:

How do I use recovery scenarios with Selenium? I used to use them with QTP.

Answer

Power of recovery scenarios lies with the programming language you use. If you are using java then you can use Exception handling to overcome same. For example if you are reading data from a file and file is not available then you should keep you code statements in “try catch” block so that test execution could continue even in the wake of errors. Such mechanism entirely boils down the errors you want to recover from, while being able to continue with test execution.

Question 73:

How do I iterate through options in my test script.

Answer

You can use loop features of the programming language, for example you can use “for” loop in java as following to type different test data in a text box –

             // test data collection in an array

            String[] testData = {"test1", "test2", "test3"};

    

     // iterate through each test data

     for (String s : testData) {

160 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 161: General technical interview questions

              selenium.type(“elementLocator”, testData);     

     }

Question 74:

Can I execute java script from my tests? I want to count number of images on my page.

Answer

You can use method getEval() to evaluate java script. For example if you want to count number of images then you can pass following dom statement to getEval() as following –

            selenium.getEval("window.document.images.length;");

Or to get All anchor objects from a page

            selenium.getEval("window.document.getElementsByTagName(‘a’);");

Question 75:

Is there a way for me to know all available options when I start Selenium Server?

Answer

If you want to see all options available while starting Selenium server then you should use option “-h” while starting Selenium server -

            Java –jar .jar –h

It would display you all the options which you can use while starting the Selenium server.

Question 76:

I have created my own firefox profile; can I execute my test scripts on it

Answer

You may like to create your own firefox profile because Selenium always created a clean firefox profile while executing the tests and none of your FF settings and plug-in are considered with this clean profile. If you want to execute tests on FF with your settings then you should create custom profile for FF.

To be able to execute tests on a custom firefox profile you should specify its path while starting Selenium server. For example if your new profile is stored at “awesome location” in your directory then you should start Selenium server as following –

Java –jar .jar -firefoxProfileTemplate   "awesome location"  

Question 77:

How do I capture server side log from Selenium server?

Answer

Start your Selenium Server as following –

java -jar .jar -log selenium.log

161 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 162: General technical interview questions

And Selenium would start logging server side info, i.e.

20:44:25 DEBUG [12] org.openqa.selenium.server.SeleniumDriverResourceHandler -

Browser 12345/:top frame1 posted START NEW

Question 78:

What are Heightened Privileges Browsers?

Answer

Firefox and IE have browser modes which are not restricted by java script’s same origin policy. These browsers are known as browsers with elevated security privileges. In case of Firefox it is known as chrome (It’s not the Google browser) and in case of IE it is known as iehta

Question 79:

My application has lots of pop up window, how do I work with them?

Answer

You need to know the Window ID of pop window to be able to work with them.

First you need to bring control on pop up window; execute selenium commands there, close the pop up window and then bring control back to main window. Consider following example where click on an image brings a pop up window –

                         // click on image brings pop up window

selenium.click("css=img");

         

// wait for pop up window identified using anchor target "ss"

          selenium.waitForPopUp("ss", getWaitPeriod());

          selenium.selectWindow("ss");

         

          // Some more operations on popup window

// Close the pop up window and Select the main application window    

          // Main window is selected by adding null as argument

          selenium.close();

          selenium.selectWindow("null");

          // continue with usual operation 

Question 80:

While trying to execute my tests with firefox I encountered following error – “Firefox Refused Shutdown While Preparing a Profile”. How do I solve it?

Answer

162 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 163: General technical interview questions

This message simply means that Selenium is not able to launch FF browser as it is already running on your system. To overcome this you should close all running instances of FF browser.

You should also check your system process if there is any hidden FF profile running which is not visible on screen. You should kill all FF processes and following this your tests should run smooth

Question 80:

While trying to execute my tests with firefox I encountered following error – “Firefox Refused Shutdown While Preparing a Profile”. How do I solve it?

Answer

This message simply means that Selenium is not able to launch FF browser as it is already running on your system. To overcome this you should close all running instances of FF browser.

You should also check your system process if there is any hidden FF profile running which is not visible on screen. You should kill all FF processes and following this your tests should run smooth

Question 81:My application uses Ajax heavily how do I use Selenium RC to work with Ajax operations?

Answer

Ajax operations don’t reload a page like normal form submission but they make http requests behind the scene. You cannot use waitForPageToLoad for such operations and instead should use conditional wait for change in state of application. This could as well mean waiting for presence of an element before continuing with test operations. Consider following example in which type operation triggers Ajax operation which is followed by conditional wait for presence of a text box –

// type operation brings element “q” on screen without loading the page

selenium.type("elementLocator", "testData");

// conditional wait for element “q”

for (int second = 0;; second++) {

     if (second >= 60) fail("timeout");

try { if (selenium.isElementPresent("q")) break; } catch (Exception e) {}

          Thread.sleep(1000);

}

Question 82:

How do I upload a file using Selenium? I need to upload a word file during test execution.

Answer

If you are using Firefox then you can use “type” command to type in a File Input box of upload file. But type operation does not work with IE and you would have to use “Robot” class in java to work make file upload work.

163 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 164: General technical interview questions

Question 83:

Why do I get “permission denied” error during execution of Selenium tests?

Answer

The primary reason of permission denied error is same origin policy restriction from java script. To overcome this error you can use browsers with elevated security privileges. In case of Firefox you should use *chrome and in case of IE you should use *iehta as browser for working with Selenium.

Question 84:

I am not able to use “style” attribute to locate element with IE browser

Answer

This is because IE expects attribute values to be in caps while other browsers expect it to be lower case letters. Hence

//tr[@style="background-color:yellow"] works with other browsers

//tr[@style="BACKGROUND-COLOUR:yellow"] works with IE

Question 85:

Are there any technical limitations while using Selenium RC?

Answer

Besides notorious “same origin policy” restriction from js, Selenium is also restricted from exercising anything which is outside browser. For example you cannot click on “Tools” option of your browser by just using Selenium.

Question 86:

But my tests need me to exercise objects outside browser, how do I achieve it?

Answer

You can use Robot class in java to achieve this, but it would be dirty solution even if you get through this.

Question 87:

Does Selenium have any offering for mobile browsers?

Answer

Selenium 2.0 (WebDriver) provides iPhone as well Android drivers which could be used to drive tests on mobile browsers

Question 88:

How does Selenium RC stand with other commercial tools?

Answer

164 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 165: General technical interview questions

The biggest advantage of Selenium RC is that it is absolutely free and has vast support of languages and browsers (almost always). Selenium lags when it comes to test reporting as Selenium does not have any in built reporting but this can be easily achieved using the programming language you decide to work on with Selenium. A bigger drawback is not being able to exercise objects which are outside browser window, for example clicking on folder on your desktop.

Question 89:

How does Selenium RC stand with other commercial tools?

Answer

The biggest advantage of Selenium RC is that it is absolutely free and has vast support of languages and browsers (almost always). Selenium lags when it comes to test reporting as Selenium does not have any in built reporting but this can be easily achieved

Question 90:

Can I just use Selenium RC to drive tests on two different browsers on one operating system without using Selenium Grid?

Answer

If you are using java client driver of Selenium then java testing framework TestNG lets you achieve this. You can set tests to be executed in parallel using “parallel=test” attribute and define two different tests, each using a different browser. Whole set up would look as  (notice the highlighted sections for browser in test suite)–

xml version="1.0" encoding="utf-8"?>

DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="Test Automation" verbose="10">

     <parameter name="serverHost" value="localhost" />

     <parameter name="appURL" value="http://tamil.yahoo.com"/>

     <parameter name="proxyInjection" value="false" />

     <parameter name="serverPort" value="4444"/>

         <test name="Web Test1">

          <parameter   name="browser"   value="*chrome"   />

          <parameter name="m" value="1">parameter>

<classes><class name="com.core.tests.TestClass1">class>classes>

     test>  

        <test name="Web Test2">

          <parameter   name="browser"   value="*iehta"   />

          <parameter name="m" value="2">parameter>

165 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 166: General technical interview questions

<classes><class name="com.core.tests.TestClass1">class>classes>

     test>

 suite>

Selenium Grid Questions

Question 91:

How do I cut down text execution time for my selenium tests? I want to execute my tests on a combination of different machines and browsers.

Answer

Selenium grid is your friend. Selenium grid lets you distribute tests across browsers and machines of your choice.

Question 92:

How does Selenium grid works?

Answer

Selenium grid uses combination of Selenium RC servers to execute tests in multiple browsers on different machine. Herein one Selenium RC server works as hub while other RC servers work as slaves, which could be controlled by hub. Whenever there is a request for a specific configuration for test execution then hub looks for a free RC slave server and if available then test execution begins on it. Once test execution is over then RC slave server would be available for next set of test execution.

Question 93:

Can you show me one diagram which describes functionality of Selenium grid?

Answer

In the following diagram Selenium hub is controlling three Selenium RC servers which are running for configurations –

IE on Windows FF on Linux FF on windows

Question 94:

Which jar files are needed to works with Selenium GRID?

Answer

You need to download and add following jar files to your Selenium set up to be able to work with Selenium. These jar files are –

selenium-grid-remote-control-standalone-.jar selenium-grid-hub-standalone-.jar selenium-grid-tools-standalone-.jar

Question 95:

How do I start Selenium Grid hub from my machine?

166 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 167: General technical interview questions

Answer

You should have “ant” set up on your system to be able to work with Grid. Once you have downloaded Selenium Grid, navigate to its distribution directory and execute following command -

ant launch-hub

This would start grid hub on port 4444 locally. You can verify this by navigating to following URL - http://localhost:4444/console

Question 96:

How do I start Selenium Grid Slave Server from my system?

Answer

Navigate to download directory of Selenium gird and execute following command –

            ant launch-remote-control

This would launch remote control server at port 555. At this point if you navigate to http://localhost:4444/console then you would see this remote control listed under “Available Remote Controls”

Question 97:

How do I start Selenium grid slave on a different port than 5555?

Answer

You can use option “-Dport” followed by port number to start grid slave on a specific port.

ant -Dport=1111 launch-remote-control

ant -Dport=2222 launch-remote-control

Question 98:

How do I start grid RC slaves on a different system than my local host so than hub could control and contact a specific configuration?

Answer

You should specify following configuration while starting RC slave –

ant -Dport= -Dhost= -DhubURL= launch-remote-control

Herein “hostname” is the host where RC slave is running and “hub url” is URL of machine where grid hub is running.

Question 99:

How do I specify an environment while starting grid slave machine?

Answer

You could specify an environment using “-Denvironment” while starting a slave machine.

                ant -Denvironment=”Safari on Mac” launch-remote-control

167 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 168: General technical interview questions

Herein Safari on Mac is the environment which would be used to recognize configuration of RC slave.

Question 100:

How do I use machine specific configuration in my Selenium tests?

Answer

You could specify machine specific configuration while instantiating Selenium as –

Selenium = new DefaultSelenium("localhost", 4444, **'Safari on Mac'**, 'http://yahoo.com');

And then you use this selenium instance to carryout operation on your web application.

Question 101:

But how does my tests know that ‘Safari on Mac’ mean a safari browser? How does mapping between names like ‘Safari on Mac’ and original browser options available in Selenium work?

Answer

Selenium grid uses a file called “grid_configuration.yml” which defines configurations of all browsers. You would have to add this in your project. This file looks like –

Question 102:

How does Selenium grid hub keeps in touch with RC slave machine?

Answer

Selenium grid hub keeps polling all RC slaves at predefined time to make sure they are available for testing. If not then Selenium hub disconnect any unavailable RC slaves and makes it clear that any RC slave is not available for testing. The deciding parameter is called – “remoteControlPollingIntervalInSeconds” and is defined in “grid_configuration.yml” file.

Question 103:

My RC becomes unresponsive at times and my Selenium grid hub keeps waiting for RC slave to respond. How do I let hub know to give up on RC slave after a certain time?

Answer

You could state Selenium grid hub to wait for RC slave for a predefined time, and if RC slave does not responds with in this time then hub disconnects test execution on that slave. This parameter is called “sessionMaxIdleTimeInSeconds” and this parameter can be defined in “grid_configuration.yml” file.

Question 104:

What if my hub goes down while Selenium RC slaves are up and running?

Answer

There is one heart beat mechanism from RC slave to hub which is reciprocal to mechanism used by hub to slave machines. RC slaves use a parameter called “hubPollerIntervalInSeconds” to keep track of running grid hub. This parameter can be defined while starting the hub as –

ant -DhubPollerIntervalInSeconds= launch-hub 

168 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 169: General technical interview questions

if hub does not respond within this time then RC slaves deregister themselves from hub.

Question 105:

Can Selenium grid be used for performance testing?

Answer

Selenium grid is for functional testing of application across different configuration. Performance testing is usually not carried out on actual devices but on a simulated http request/response mechanism. If you want to use Selenium Grid for performance testing then you would have to invest heavily on s/w and h/w infrastructure.

Question 106:

Are there additional logs available while working with Selenium grid?

Answer

You can find Selenium grid hub logs in “log/hub.log” and Remote Control logs in “log/rc-*.log” folder.

Question 107:

There are various options available while starting a Selenium server, how do I use them with Selenium grid?

Answer

You can use “seleniumArgs” Java property while launching the remote control and specify any of the option which you would with normal Selenium set up. For example you can run Selenium RC slave in single window mode using following command –

ant -DseleniumArgs="-singleWindow -debug" launch-remote-control

Question 108:

I see duplicate entries in my hub console, same RC slave listed more than once :-O

Answer

This is because you are killing RC slave very ferociously. For example you if you just close the console without actually ending the process in more civil manner. To avoid this you should kill all RC slaves in more civil manner. If you encounter this error then you should restart Selenium hub and RC slaves would them register themselves to hub.

Question 109:

How do I specify my corporate proxy while starting Selenium grid hub or slave machines?

Answer

You could use setting for “http.proxyHost” abd “http.proxyPort” while starting hub and remote control machines –

ant -Dhttp.proxyHost= -Dhttp.proxyPort= launch-hub

ant -Dhttp.proxyHost= -Dhttp.proxyPort= launch-remote-control

Question 110:

169 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 170: General technical interview questions

How do I use Selenium Grid while using Java, .Net or Ruby

Answer

With java you can take advantage of parallel testing capabilities of TestNG to drive your Selenium grid tests

With .Net you can use “Gallio” to execute your tests in parallel

With Ruby you can use “DeepTest” to distribute your tests

Question 111:

How about the test report when I use Selenium grid for test execution?

Answer

This entirely boils down to framework you use to write your tests. For example in case of java, TestNG reports should suffice.

Web Driver (Selenium 2.0) Questions

Question 112:

What is Selenium 2.0? I have heard this buzz word many times.

Answer

Selenium 2.0 is consolidation of two web testing tools – Selenium RC and WebDriver, which claims to give best of both words – Selenium and WebDriver. Selenium 2.0 was officially released only of late.

Question 113:

Why are two tools being combined as Selenium 2.0, what’s the gain?

Answer

Selenium 2.0 promises to give much cleaner API then Selenium RC and at the same time not being restricted by java script Security restriction like same origin policy, which have been haunting Selenium from long. Selenium 2.0 also does not warrant you to use Selenium Server.

Question 114:

So everyone is going to use Selenium 2.0?

Answer

Well no, for example if you are using Selenium Perl client driver than there is no similar offering from Selenium 2.0 and you would have to stick to Selenium 1.0 till there is similar library available for Selenium 2.0

Question 115:

170 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 171: General technical interview questions

So how do I specify my browser configurations with Selenium 2.0?

Answer

Selenium 2.0 offers following browser/mobile configuration –

AndroidDriver, ChromeDriver, EventFiringWebDriver, FirefoxDriver, HtmlUnitDriver, InternetExplorerDriver, IPhoneDriver, IPhoneSimulatorDriver, RemoteWebDriver

And all of them have been implemented from interface WebDriver. To be able to use any of these drivers you need to instantiate their corresponding class.

Question 116:

How is Selenium 2.0 configuration different than Selenium 1.0?

Answer

In case of Selenium 1.0 you need Selenium jar file pertaining to one library for example in case of java you need java client driver and also Selenium server jar file. While with Selenium 2.0 you need language binding (i.e. java, C# etc) and Selenium server jar if you are using Remote Control or Remote WebDriver.

Question 117:

Can you show me one code example of setting Selenium 2.0?

Answer

Here is java example of initializing firefox driver and using Google Search engine –

protected WebDriver webDriver;

    

     //@BeforeClass(alwaysRun=true)

     public void startDriver(){

     webDriver = new FirefoxDriver();

     // Get Google search page and perform search on term “Test”

webDriver.get("http://www.google.com");

     webDriver.findElement(By.name("q")).sendKeys("Test");

     webDriver.findElement(By.name(“btnG”)).click();

Question 118:

Which web driver implementation is fastest?

171 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 172: General technical interview questions

Answer

HTMLUnitDriver. Simple reason is HTMLUnitDriver does not execute tests on browser but plain http request – response which is far quick than launching a browser and executing tests. But then you may like to execute tests on a real browser than something running behind the scenes

Question 119:

What all different element locators are available with Selenium 2.0?

Answer

Selenium 2.0 uses same set of locators which are used by Selenium 1.0 – id, name, css, XPath but how Selenium 2.0 accesses them is different. In case of Selenium 1.0 you don’t have to specify a different method for each locator while in case of Selenium 2.0 there is a different method available to use a different element locator. Selenium 2.0 uses following method to access elements with id, name, css and XPath locator –

driver.findElement(By.id("HTMLid"));

driver.findElement(By.name("HTMLname"));

driver.findElement(By.cssSelector("cssLocator"));

driver.findElement(By.xpath("XPathLocator));

Question 120:

How do I submit a form using Selenium?

Answer

You can use “submit” method on element to submit form –

element.submit();

Alternatively you can use click method on the element which does form submission.

Question 121:

Can I simulate pressing key board keys using Selenium 2.0?

Answer

You can use “sendKeys” command to simulate key board keys as –

            element.sendKeys(" and some", Keys.ARROW_UP);

You can also use “sendKeys” to type in text box as –

            HTMLelement.sendKeys("testData");

Question 122:

How do I clear content of a text box in Selenium 2.0

172 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 173: General technical interview questions

Answer

You can use “clear” method on text box element to clear its content –

            textBoxElement.clear();   

Question 123:

How do I select a drop down value using Selenium2.0?

Answer

To select a drop down value, you first need to get the select element using one of element locator and then you can select element using visible text –

Select selectElement = new Select(driver.findElement(By.cssSelector("cssSelector")));

          selectElement.selectByVisibleText("India");

Question 124:

What are offering to deal with popup windows while using Selenium 2.0?

Answer

You can use “switchTo” window method to switch to a window using window name. There is also one method “getWindowHandles” which could be used to find all Window handles and subsequently bring control on desired window using window handle –

webDriver.switchTo().window("windowName");

          for (String handle : driver.getWindowHandles()) {

              driver.switchTo().window(handle);

          }

 Question 125:

How about handling frames using Selenium 2.0?

Answer

You can use “switchTo” frame method to bring control on an HTML frame –

            driver.switchTo().frame("frameName");

You can also use index number to specify a frame –

            driver.switchTo().frame("parentFrame.4.frameName");

This would bring control on frame named – “frameName” of the 4th sub frame names “parentFrame”

Question 126:

Can I navigate back and forth in a browser in Selenium 2.0?

173 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 174: General technical interview questions

Answer

You can use Navigate interface to go back and forth in a page. Navigate method of WebDriver interface returns instance of Navigation. Navigate interface has methods to move back, forward as well as to refresh a page –

driver.navigate().forward();driver.navigate().back();driver.navigate().refresh();

  Question 127:What is the order of fastest browser implementation for WebDriver?

Answer

HTMLUnitDriver is the fastest browser implementation as it does not involves interaction with a browser, This is followed by Firefox driver and then IE driver which is slower than FF driver and runs only on Windows.  Question 128:

Is it possible to use Selenium RC API with Selenium 2.0?

Answer

You can emulate Selenium 1.0 API with Selenium 2.0 but not all of Selenium 1.0 methods are supported. To achieve this you need to get Selenium instance from WebDriver and use Selenium methods. Method executions might also be slower while simulating Selenium 1.0 with in Selenium 2.0 Question 129:

Can you show me one example of using Selenium 1.0 in Selenium 2.0?

Answer

Code Sample:

// Create web driver instance

     WebDriver driver = new FirefoxDriver();

     // App URL

     String appUrl = "http://www.google.com";

     // Get Selenium instance

Selenium selenium = new   WebDriverBackedSelenium(driver, appUrl) ;

     // Tests using selenium

     selenium.open(appURL);

     selenium.type("name=q", "testData");

174 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 175: General technical interview questions

     selenium.click("name=btnG");

     // Get back the WebDriver instance

WebDriver driverInstance = ((WebDriverBackedSelenium) selenium).getUnderlyingWebDriver();

Question 130:I had support of lots of browsers while using Selenium 1.0 and it seems lacking with Selenium 2.0, for example how do I use < awesome> browser while using Selenium 2.0?

Answer

There is a class called Capabilities which lets you inject new Capabilities in WebDriver. This class can be used to set testing browser as Safari –

//Instantiate Capabilities

     Capabilities capabilities = new DesiredCapabilities()

              //Set browser name

     capabilities.setBrowserName("this awesome browser");

         

     //Get your browser execution capabilities

CommandExecutor executor = new   SeleneseCommandExecutor("http:localhost:4444/",   "http://www.google.com/", capabilities) ;

     //Setup driver instance with desired Capabilities

WebDriver driver = new RemoteWebDriver(executor, capabilities);

Question 131:Are there any limitations while injecting capabilities in WebDriver to perform tests on a browser which is not supported by WebDriver?

Answer

Major limitation of injecting Capabilities is that “fundElement” command may not work as expected. This is because WebDriver uses Selenium Core to make “Capability injection” work which is limited by java script security policies.

Question 132:

Can I change User-Agent while using FF browser? I want to execute my tests with a specific User-Agent setting.

Answer

You can create FF profile and add additional Preferences to it. Then this profile could be passed to Firefox driver while creating instance of Firefox –

FirefoxProfile profile = new FirefoxProfile();

profile.addAdditionalPreference("general.useragent.override", "User Agent String");

175 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 176: General technical interview questions

     WebDriver driver = new FirefoxDriver(profile);

Question 133:

Is there any difference in XPath implementation in different WebDriver implementations?

Answer

Since not all browsers (like IE) have support for native XPath, WebDriver provides its own implementation for XPath for such browsers. In case of HTMLUnitDriver and IEDriver, html tags and attributes names are considered lower cased while in case of FF driver they are considered case in-sensitive.

Question 134:

My application uses ajax highly and my tests are suffering from time outs while using Selenium 2.0.

Answer

You can state WebDriver to implicitly wait for presence of Element if they are not available instantly.  By default this setting is set to 0. Once set, this value stays till the life span of WebDriver object. Following example would wait for 60 seconds before throwing ElementNotFound exception –

WebDriver driver = new FirefoxDriver();

driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

WebElement element = driver.findElement(By.id("elementID"));

Question 135:

What if I don’t want to use implicit wait and want to wait only for presence of certain elements?

Answer

You can use explicit wait in this situation to wait for presence of certain element before continuing with test execution. You can use “WebDriverWait” and “ExpectedCondition” to achieve this –

WebDriver driver = new FirefoxDriver();

WebElement myDynamicElement = (new WebDriverWait(driver, 60)).until(new ExpectedCondition<WebElement>(){

@Override

     public WebElement apply(WebDriver d) {

          return d.findElement(By.id("myDynamicElement"));

     }});

This is going to wait up to 60 seconds before throwing ElementNotFound exception.

Question 136:

What is RemoteWebDriver? When would I have to use it?

176 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 177: General technical interview questions

Answer

RemoteWebDriver is needed when you want to use HTMLUnitDriver. Since HTMLUnitDriver runs in memory, you would not see a browser getting launched –

             

        // Create HTMLUnitDriver instance

        WebDriver driver = new HtmlUnitDriver();

        // Launch Yahoo.com

        driver.get("http://www.yahoo.com");

Question 137:

What all languages available to be used with WebDriver?

Answer

Java and C# are on the forefront of WebDriver languages. Support is also available for Python and Ruby. There is also one java script library available for Friefox.

Question 138:

How do I handle java script alert using WebDriver?

Answer

WebDriver would support handling js alerts using Alert interface.

                 // Bring control on already opened alert

          Alert alert = driver.switchTo().alert();

          // Get the text of the alert or prompt

          alert.getText(); 

        // Click ok on alert

          alert.accept();

Question 139:

Could I safely execute multiple instances of WebDriver implementations?

Answer

As far as HTMLUnitDriver and FF drivers are concerned, each instance would be independent of other. In case of IE driver there could be only one instance of IE driver running on Windows. If you want to execute more than one instance of IE driver then you should consider using RemoteWebDriver and virtual machines.

Question 140:

177 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 178: General technical interview questions

Is it possible to interact with hidden elements using WebDriver?

Answer

Since WebDriver tries to exercise browser as closely as real users would, hence simple answer is No, But you can use java script execution capabilities to interact with hidden elements.

Question 141:

I have all my tests written in Selenium 1.0 (Selenium RC), why should I migrate to Selenium 2.0 (WebDriver)?

Answer

Because –

WebDriver has more compact and object oriented API than Selenium 1.0 WebDriver simulates user behaviour more closely than Selenium 1.0, for example if a text

box is disabled WebDriver would not be able to type text in it while Selenium 1.0 would be WebDriver is supported by Browser vendor themselves i.e. FF, Opera, Chrome etc

Question 142:

My XPath and CSS locators don’t always work with Selenium 2.0, but they used to with Selenium 1.0.

Answer

In case of XPath, it is because WebDriver uses native browser methods unless it is not available. And this cause complex XPath to be broken. In case of Selenium 1.0 css selectors are implemented using Sizzle Library and not all the capabilities like “contains” are available to be used with Selenium 2.0

Question 143:

How do I execute Java Script in Selenium 2.0?

Answer

You need to use JavaScriptExecutor to execute java script in Selenium 2.0, For example if you want to find tag name of an element using Selenium 2.0 then you can execute java script as following –

WebElement element = driver.findElement(By.id("elementLocator"));

String name = (String) ((JavascriptExecutor) driver).executeScript(

    "return arguments[0].tagName", element);

Question 144:

Why does not my java script execution return any value?

Answer

This might happen when you forget to add “return“ keyword while executing java script. Notice the “return” keyword in following statement –

((JavascriptExecutor) driver).executeScript("return window.title;");

Question 145:

178 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 179: General technical interview questions

Are there any limitations from operating systems while using WebDriver?

Answer

While HTMLUnitDriver, FF Driver and Chrome Driver could be used on all operating systems, IE Driver could be used only with Windows.

Question 146:

Give me architectural overview of WebDriver.

Answer

WebDriver tries to simulate real user interaction as much as possible. This is the reason why WebDriver does not have “fireEvent” method and “getText” returns the text as a real user would see it. WebDriver implementation for a browser is driven by the language which is best to driver it. In case of FF best fit languages are Javascript in an XPCOM component and in IE it is C++ using IE automation.  Now the implementation which is available to user is a thin wrapper around the implementation and user need not know about implementation.

Question 147:

What is Remote WebDriver Server?

Answer

Remote WebDriver Server has two components – client and server. Client is WebDriver while Server is java servlet. Once you have downloaded selenium-server-standalone-.jar file you can start it from command line as –

        java -jar selenium-server-standalone-<version-number>.jar

Question 148:

Is there a way to start Remote WebDriver Server from my code?

Answer

First add Remote WebDriver jar in your class path. You also need another server called “Jetty” to use it. You can start sever as following –

                        WebAppContext context = new WebAppContext();

         context.setContextPath("");

         context.setWar(new File("."));

         server.addHandler(context);

         context.addServlet(DriverServlet.class, "/wd/*");

SelectChannelConnector connector = new SelectChannelConnector();

         connector.setPort(3001);

         server.addConnector(connector);

         server.start();

179 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 180: General technical interview questions

Question 149:

But what are the advantages of using Remote WebDriver over WebDriver?

Answer

You can use Remote WebDriver when –

When you want to execute tests on a browser not available to you locally Introduction to extra latency to tests

But there is one disadvantage of using Remote WebDriver that you would need external servlet container.

Question 150:

Can you show me code example of using Remote WebDriver?

Answer

// Any driver could be used for test

DesiredCapabilities capabilities = new DesiredCapabilities();

          // Enable javascript support

          capabilities.setJavascriptEnabled(true);

          // Get driver handle

          WebDriver driver = new RemoteWebDriver(capabilities);

          // Launch the app

          driver.get("http://www.google.com");

Question 151:

What are the modes of Remote WebDriver

Answer

Remote WebDriver has two modes of operations –

Client Mode: This is where language bindings connect to remote instance. FF drive and RemoteWebDriver clients work this way.

Server Mode: In this mode language bindings set up the server. ChromeDriver works this way.

Question 152:

What Design Patterns could be used while using Selenium 2.0?

Answer

These three Design Patterns are very popular while writing Selenium 2.0 tests –

Page Objects – which abstracts UI of web page

180 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 181: General technical interview questions

Domain Specific Language – which tries to write tests which could be understood by a normal user having no technical knowledge

Bot Style Tests – it follows “command-like” test scripting

Question 153:

So do I need to follow these Design patterns while writing my tests?

Answer

Not at all, these Design Patterns are considered best practices and you can write you tests without following any of those Design Patterns, or you may follow a Design Pattern which suites your needs most.

Question 154:

Is there a way to enable java script while using HTMLUnitDriver?

Answer

Use this –

HtmlUnitDriver driver = new HtmlUnitDriver();

     driver.setJavascriptEnabled(true);

or this –

     HtmlUnitDriver driver = new HtmlUnitDriver(true);

Question 155:

Is it possible to emulate a browser with HTMLUnitDriver?  

Answer

You can emulate browser while using HTMLUnitDriver but it is not recommended as applications are coded irrespective of browser you use. You could emulate Firefox 3 browser with HTMLUnitDriver as –

HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_3);

Or you can inject desired capabilities while instantiating HTMLUnitDriver as –

HtmlUnitDriver driver = new HtmlUnitDriver(capabilities);

Question 156:

How do I use iPhone Driver?

Answer

You should start iPhone SDK and build iPhone driver. Down load iPhone development tools and provision profile. Now iPhone driver can connect through HTTP to the iphone simulator. You can also run simulator on another machine in your network and WebDriver could connect to it remotely.

Question 157:

181 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 182: General technical interview questions

Is it possible to convert Selenium IDE test to WebDriver test?

Answer

For now there is no formatter available to convert Selenium IDE tests to corresponding WebDriver tests, hence simple answer is No. Yes WebDriver style of code can be generated from Selenium IDE 

Question 158:

Can WebDriver handle UntrustedSSLCertificates?

Answer

This feature is currently supported in Firefox browser and is awaiting implementation in IE and Chrome drivers.

Question 159:

Can I carry out multiple operations at once while using WebDriver?

Answer

You can use Builder pattern to achieve this. For example if you want to move an element from one place to another you can use this –

          Actions builder = new Actions(driver);

          Action dragAndDrop = builder.clickAndHold(element)

                 .moveToElement(otherElement)

                 .release(otherElement)

                 .build();

          dragAndDrop.perform();

Question 160:

How do I simulate keyboard keys using WebDriver?

Answer

There is a KeyBoard interface which has three methods to support keyboard interaction –

sendKeys(CharSequence)- Sends character sequence pressKey(Keys keyToPress) - Sends a key press without releasing it. releaseKey(Keys keyToRelease) - Releases a modifier key

Question 161:

What about Mouse Interaction?

Answer

Mouse interface lets you carry out following operations –

182 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 183: General technical interview questions

click(WebElement element) – Clicks an element doubleClick(WebElement element) - Double-clicks an element. void mouseDown(WebElement element) - Holds down the left mouse button on an element. mouseUp(WebElement element) - Releases the mouse button on an element. mouseMove(WebElement element) - Moves element form current location to another

element. contextClick(WebElement element) - Performs a context-click (right click) on an element.

Question 162:

How does Android Webdriver works?

Answer

Android WebDriver uses Remote WebDriver. Client Side is test code and Server side is application installed on android emulator or actual device. Here client and server communicate using JSON wire protocol consisting of Rest requests.

Question 163:

What are the advantages of using Android WebDriver?

Answer

Android web driver runs on Android browser which is best real user interaction. It also uses native touch events to emulated user interaction.

But there are some drawbacks also like, it is slower than headless WebKit driver. XPath is not natively supported in Android web view.

Question 164:

Is there a built-in DSL (domain specific language) support available in WebDriver?

Answer

There is not, but you can easily build your own DSL, for example instead of using –

webDriver.findElement(By.name("q")).sendKeys("Test");

You can create a more composite method and use it –

public static void findElementAndType(WebDriver webDriver, String elementLocator, String testData) {

webDriver.findElement(By.name(elementLocator)).sendKeys(testData);

     }

And now you just need to call method findElementAndType to do type operation.

Question 165:

What is grid2?

Answer

Grid2 is Selenium grid for Selenium 1 as well as WebDriver, This allows to –

Execute tests on parallel on different machines

183 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 184: General technical interview questions

Managing multiple environments from one point

Question 166:

How do I start hub and slaves machines in grid 2?

Answer

Navigate to you selenium server standalone jar download and execute following command –

java -jar selenium-server-standalone-.jar -role hub And you start Slave machine by executing following command – Java –jar selenium-server-.jar –role webdriver  -hub http://localhost:4444/grid/register -port 6666 Question 167:

And how do I run tests on grid?

Answer

You need to use the RemoteWebDriver and the DesiredCapabilities object to define browser, version and platform for testing. Create Targeted browser capabilities as –DesiredCapabilities capability = DesiredCapabilities.firefox(); Now pass capabilities to Remote WebDriver object – WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);Following this, hub will take care of assigning tests to a slave machine

Question 168:

What parameters can be passed to grid2?

Answer

You can pass following parameters to grid 2 –

-port 4444 (default 4444) -nodeTimeout (default 30) the timeout in seconds before the hub automatically releases a

node that hasn't received any requests for more than the specified number of seconds. -maxConcurrent 5 (5 is default) The maximum number of browsers that can run in parallel

on the node.

Selenium Tool Implementation Misc Questions

Question 169:

How do I implement data driven testing using Selenium?

Answer

Selenium, unlike others commercial tools does not have any direct support for data driven testing. Your programming language would help you achieving this. You can you jxl library in case of java to read and write data from excel file. You can also use Data Driven Capabilities of TestNG to do data driven testing.

Question 170:

What is equivalent to test step, test scenario and test suite in Selenium.

184 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 185: General technical interview questions

Answer

If you are using Java client driver of Selenium then TestNG test method could be considered equivalent to test step, a test tag could be considered as test scenario and a suite tag could be considered equivalent to a test suite.

Question 171:

How do I get attribute value of an element in Selenium?

Answer

You could use getAttribute method

With Selenium 1.0 –

        String var = selenium.getAttribute("css=input[name='q']@maxlength");        System.out.println(var);

With Selenium 2.0 –

String var = webDriver.findElement(By.cssSelector("input[name='q']")).getAttribute("maxlength")

        System.out.println(var);

Question 172:

How do I do database testing using Selenium?

Answer

Selenium does not support database testing but your language binding does. For example while using java client driver you can use java data base connectivity (jdbc) to establish connection to data base, fetch/write data to data base and doing data comparison with front end.

Question 173:

I completed test execution and now I want to email test report.

Answer

If you are using “ant” build tool then you can use “mail” task to deliver your test results. Similar capabilities are available in Continuous Build Integration tools like – Hudson.

Question 174:

How do I make my tests more comprehensible?

Answer

Selenium tests which are written as –

        selenium.click("addForm:_ID74:_ID75:0:_ID79:0:box”);

Make it tough to understand the element which is being exercised upon.

185 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 186: General technical interview questions

Instead of hard coding element locator in tests you should externalize them. For example with java you can use properties file to contain element locators and then locator reference is given in test script. Following this approach previous test step would look as –

      selenium.click(PolicyCheckbox);

And this is far more comprehensible.

Question 175:

Why should I use Page Object?

Answer

Page object is a design pattern which distinguishes the code carrying out operations on page and code which carries out tests (assertion/verification). While implementing page object you abstract functioning of a page or part of it in a dedicated “Classs” which is then used by test script to perform actions on page and reach a stage when actual test could be performed.

Advantage of using page object is the fact that if application lay out changes then you only need to modify the navigation part and test would function intact.

Selenium Interview Questions, Java Selenium Interview Questions 2012

1. What is Selenium?

2. What are the main components of Selenium testing tools? 

3. What is Selenium IDE? 

4. What is the use of context menu in Selenium IDE? 

5. Can tests recorded using Selenium IDE be run in other browsers? 

6. What are the advantage and features of Selenium IDE?

7. What are the disadvantage of Selenium IDE tool? 

8. What is Selenium RC (Remote Control)? 

9. What is Selenium Grid?

10. How Selenium Grid works?

11. What you say about the flexibility of Selenium test suite?

12. What test can Selenium do? 

13. What is the cost of Selenium test suite? 

14. What browsers are supported by Selenium Remote Control? 

15. What programming languages can you use in Selenium RC? 

16. What are the advantages and disadvantages of using Selenium as testing tool? 

17. What is difference between QTP and Selenium? 

186 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 187: General technical interview questions

18. What do you know about Selenium?

19. What are the technical challenges with selenium?

20. What are the test types supported by Selenium?

21. What are the capabilities of Selenium IDE?

22. What are the challenges with Selenium IDE?

23. Which are the browsers supported by Selenium IDE?

24. How to execute a single line command from Selenium IDE?

25. How to insert a start point in Selenium IDE?

26. How to insert a comment in Selenium IDE?

27. How to insert a break point in Selenium IDE?

28. How to debug the tests in Selenium IDE?

29. How to export the tests from Selenium IDE to Selenium RC in different languages?

30. How to capture bitmaps in Selenium?

31. Which is the command used for displaying the values of a variable into the output

console or log?

32. Which are the browsers supported by Selenium RC?

33. Which are the Operating Systems supported by Selenium?

34. What is Selenium RC?

35. Why Selenium RC is used?

36. Which are the languages supported by Selenium RC?

37. When to use Accessors in Selenium?

38. What is Selenium WebDriver or Google WebDriver or Selenium 2.0?

39. What are the capabilities of Selenium WebDriver or Google WebDriver or Selenium

2.0?

40. What is the architecture of Selenium RC?

41. What is the architecture of Selenium Grid?

42. Does Selenium support mobile internet testing?

43. Does Selenium support Google Android Operating System?

44. What are the types of text patterns available in Selenium?

45. How to use regular expressions in Selenium?

46. What is Selenese?

47. How do you add check points or verification points in Selenium?

48. What is Assertion in Selenium?

187 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 188: General technical interview questions

49. What is an Accessor in Selenium?

50. When to use Assert, Verify and WaitFor in Selenium?

How to capture bitmaps in Selenium? | Selenium

Bitmaps are captured using the Selenium set of commands. There are two modes of capturing the

bitmaps

1) Capture the bitmap for the entire page - it captures the browser main page area of AUT

2) Capture the bitmap for the screen shots - it captures the entire screen shot like the print screen

that you give from your keyboard

Selenium doesn't support bitmap capturing for an element on AUT.

When to use Accessors in Selenium? | Selenium

Accessors are mostly used for storing the value in a variable.

The variable can be used for following reasons:

1) To get the value from an element and comparing with some dynamic value

2) To take a logical decision to execute the test steps

ex: if the value of the variable true execute step1 and step2 else step3 and step4

3) To execute some statements in a loop based on the value returned by the element.

When to use Assert, Verify and WaitFor in Selenium? | Selenium

1) assert - If the expected value is mandatory to continue with the next set of steps we will use

Assert. As Assert aborts the test, if the expected value doesn't match. It is good to use for any

mandatory checks.

2) verify - If the expected value is optional to continue with the next set of steps we will use

Verify. As Verify continues executing with the next set of steps, if the expected value doesn't

match. It is good to use for any optional checks.

3) waitFor - If your test needs to wait, if the expected value is not matching we use waitFor. We

normally use waitFor for AJAX kind of controls loading within a page.

What are the types of Assertions there in Selenium? | Selenium

Selenium Assertions can be used in 3 modes:

1) assert - When an “assert” fails, the test will be aborted. If you are executing test suite, the next

state case will start

2) verify - When a “verify” fails, the test will continue execution, logging the failure.

3) waitFor - “waitFor” commands wait for some condition to become true (which can be useful for

testing Ajax applications). They will succeed immediately if the condition is already true. However,

188 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 189: General technical interview questions

they will fail and halt the test if the condition does not become true within the current timeout

setting.

What is Assertion in Selenium? | Selenium

Assertion is nothing but a check or verification point.

Assertion verifies the state of the application conforms to what is expected.

Examples include “make sure the page title is X” and “verify that this checkbox is checked.

What is Selenese? | Selenium

Selenium set of commands which are used for running the test are called as Selenese.

There are three types of Selenese, those are:

1. Actions - used for performing the operations and interactions with the target elements

2. Assertions - used as check points

3. Accessors - used for storing the values in a variable.

How to use regular expressions in Selenium? | Selenium

Regular expressions in Selenium IDE can be used with the keyword - regexp: as a prefix to the

value and patterns needs to be included for the expected values.

For example if you want to use the regular expression for a command

Command: verifyText

Target: //font/font/b/font[1]

Value: Flight Confirmation # 2011-05-02451

in the above example Flight Confirmation is continuously changing each time you run the test case.

So this can be written with a regular expression as mentioned below 

Command: verifyText

Target: //font/font/b/font[1]

Value: regexp:Flight Confirmation # [0-9]{4}-[0-9]{2}-[0-9]{5,10}.

What are the types of text patterns available in Selenium? | Selenium

There are three types of patterns available in Selenium:

1. globbing

2. regular expressions

3. exact.

Does Selenium support Google Android Operating System? | Selenium

Yes, Selenium Web Driver or Google Web Driver or Selenium 2.0 supports Android Operating

System. There are several libraries written to support Android Operating System.

Does Selenium support mobile internet testing? | Selenium

189 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 190: General technical interview questions

Selenium supports Opera. And opera is used in most of the Smart phones. So whichever Smart

phone supports opera, selenium can be used to test. So, one can use Selenium RC to run the tests

on mobiles.What is the architecture of Selenium Grid? | Selenium

The below mentioned theory explains about the setup of Selenium Grid with architecture and how

it works.

Selenium Grid builds on the traditional Selenium setup, taking advantage of the following

properties:

* The Selenium test, the application under test, and the remote control/browser pair do not have to

be co-located. They communicate through HTTP, so they can all live on different machines.

* The Selenium tests and the web application under test are obviously specific to a particular

project. Nevertheless, neither the Selenium remote control nor the browser is tied to a specific

application. As a matter of fact, they provide a capacity that can easily be shared by multiple

applications and multiple projects.

Consequently, if only we could build a distributed grid of Selenium Remote Controls, we could

easily share it across builds, applications, projects - even potentially across organizations. Of

course we would also need to address the scalability issues as described earlier when covering the

traditional Selenium setup. This is why we need a component in charge of:

* Allocating a Selenium Remote Control to a specific test (transparently)

* Limiting the number of concurrent test runs on each Remote Control

* Shielding the tests from the actual grid infrastructure 

Selenium Grid calls this component the Selenium Hub.

* The Hub exposes an external interface that is exactly the same as the one of a traditional Remote

Control. This means that a test suite can transparently target a regular Remote Control or a

Selenium Hub with no code change. It just needs to target a different IP address. This is important

as it shields the tests from the grid infrastructure (which you can scale transparently). This also

makes the developer’s life easier. The same test can be run locally on a developer machine, or run

on a heavy duty distributed grid as part of a build – without ever changing a line of code.

* The Hub allocates Selenium Remote Controls to each test. The Hub is also in charge of routing

the Selenese requests from the tests to the appropriate Remote Control as well as keeping track of

testing sessions.

* When a new test starts, the Hub puts its first request on hold if there is no available Remote

Control in the grid providing the appropriate capabilities. As soon as a suitable Remote Control

190 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 191: General technical interview questions

becomes available, the Hub will serve the request. For the whole time, the tests do not have to be

aware of what is happening within the grid; it is just waiting for an HTTP response to come back. 

What is the architecture of Selenium RC? | Selenium

The Selenium Server which launches and kills browsers, and acts as an HTTP proxy for browser

requests. 

Client libraries for various programming languages, each of which instructs the Selenium Server in

how to test the AUT by passing it your test script’s Selenium commands. 

The diagram shows the client libraries communicate with the Server passing each Selenium

command for execution. Then the server passes the Selenium command to the browser using

Selenium-Core JavaScript commands. The browser, using its JavaScript interpreter, executes the

Selenium command, which effectively, runs the check you specified in your Selenese test script.

What are the capabilities of Selenium WebDriver or Google WebDriver or Selenium 2.0? | Selenium

One should use WebDriver when requiring improved support for

• Mult-browser testing including improved functionality for browsers not well-supported by

Selenium-1.0.

• Handling multiple frames, multiple browser windows, popups, and alerts.

• Page navigation.

• Drag-and-drop.

• AJAX-based UI elements.

What is Selenium WebDriver or Google WebDriver or Selenium 2.0? | Selenium

WebDriver uses a different underlying framework from Selenium’s javascript Selenium-Core. It also

provides an alternative API with functionality not supported in Selenium-RC. WebDriver does not

depend on a javascript core embedded within the browser, therefore it is able to avoid some long-

running Selenium limitations.

WebDriver’s goal is to provide an API that establishes

• A well-designed standard programming interface for web-app testing.

• Improved consistency between browsers.

• Additional functionality addressing testing problems not well-supported in Selenium 1.0. 

The Selenium developers strive to continuously improve Selenium. Integrating WebDriver is

another step in that process. The developers of Selenium and of WebDriver felt they could make

significant gains for the Open Source test automation community be combining forces and merging

191 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 192: General technical interview questions

their ideas and technologies. Integrating WebDriver into Selenium is the current result of those

efforts.

Which are the languages supported by Selenium RC? | Selenium

The languages supported by Selenium RC

1. .Net,

2. Java (Junt 3, Junt 4, TestNG, Groovy)

3. Perl,

4. Python,

5. PHP,

6. Ruby.

Read More!

Why Selenium RC is used? | Selenium

Selenium-IDE does not directly support:

1. condition statements

2. iteration

3. logging and reporting of test results

4. error handling, particularly unexpected errors

5. database testing

6. test case grouping

7. re-execution of failed tests

8. test case dependency

9. capture screenshots on test failures 

The reason behind why Selenium-IDE does not support the above mentioned requirements is IDE

supports only HTML language. Using HTML language we cannot achieve the above mentioned

requirements. Because HTML does not support conditional, looping and external source

connectives.

To overcome the above mentioned problems Selenium RC is used.

Since Selenium RC supports the languages .Net, Java, Perl, Python, PHP, and Ruby. In these

languages we can write the programme to achieve the IDE issues

Read More!

What is Selenium RC? | Selenium

192 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 193: General technical interview questions

Selenium-RC is the solution for tests that need a little more than just simple browser actions and a

linear execution. Selenium-RC leverages the full power of programming languages, creating tests

that can do things like read and write external files, make queries to a database, send emails with

test reports, and practically anything else a user can do with a normal application.

You will want to use Selenium-RC whenever your test requires logic not supported by running a

script from Selenium-IDE

Which are the Operating Systems supported by Selenium? | Selenium

Selenium IDE 

Works in Firefox 2+ Start browser, run tests Run tests

Operating Systems Supported: 

1. Windows,

2. OS X

3. Linux

4. Solaris

5. Others whichever supports Firefox 2+ 

Selenium Remote Control 

Used for starting browser and run tests

Operating Systems Supported: 

1. Windows,

2. OS X

3. Linux

4. Solaris

5. Others 

Selenium Core 

Used for running tests

Operating Systems Supported: 

1. Windows,

2. OS X

3. Linux

4. Solaris

5. OthersWhich are the browsers supported by Selenium RC? | Selenium

193 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 194: General technical interview questions

Supported browsers for Selenium RC include:

1. *firefox

2. *mock

3. *firefoxproxy

4. *pifirefox

5. *chrome

6. *iexploreproxy

7. *iexplore

8. *firefox3

9. *safariproxy

10. *googlechrome

11. *konqueror

12. *firefox2

13. *safari

14. *piiexplore

15. *firefoxchrome

16. *opera

17. *iehta

18. *custom 

Note: Any third party browser is supported with *custom followed by the complete path of the

browser with executable

Which is the command used for displaying the values of a variable into the output console or log? | Selenium

The command used for displaying the values of a variable into the output console or log - echo

If you want to display a constant string. The below mentioned command can be used

echo <constant string>

ex: echo "The sample message"

If you want to display the value of a variable it can be written like below

echo ${<variable name>>

ex: echo ${var1}

Note: Here var1 is the variable.How to export the tests from Selenium IDE to Selenium RC in different languages? | Selenium

From selenium IDE the test cases can be exported into the languages:

1. .Net,

194 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 195: General technical interview questions

2. Java,

3. Perl,

4. Python,

5. PHP,

6. Ruby 

The below mentioned steps can explain how to export the test cases:

1. Open the test case from Selenium IDE

2. Select File -> Export Test Case As How to debug the tests in Selenium IDE? | Selenium

To debug or execute the test cases line by line. Follow the below mentioned steps

1. Insert a break point (see the question to know more How to insert a break point in Selenium IDE?

)from the location where you want to execute step by step

2. Run the test case

3. execution will be paused at the given break point

4. Click on the step (Blue) button to continue with the next statement

5. Click on Run button, to continue executing all the commands at a time.

How to insert a break point in Selenium IDE? | Selenium

Break point can be set in two ways in Selenium IDE:

1. Right click on the command in Selenium IDE and select "Toggle Break Point"

2. Select the command in Selenium IDE and press "B" key on the keyboard

3. If you want to clear the break point once again Spress "B" key on the keyboard

4. You can set multiple break points in Selenium IDE.

How to insert a comment in Selenium IDE? | Selenium

Comments in Selenium IDE can be set in two ways

1. Right click on the command in Selenium IDE and select "Inert New Comment"

2. If you want to comment an existing line. You need to follow the below mentioned steps.

a. Select the source tab in IDE

b. Select the line which you want to comment

c. Assume that if you want to comment a open command you need to write like below mentioned

code 

<tr> 

<!-- 

<td>open&l/td>

195 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 196: General technical interview questions

<td>/node/304/edit&l/td>

<td></td> 

--> 

</tr>

How to insert a start point in Selenium IDE? | Selenium

Start point Selenium IDE can be set in two ways:

1. Right click on the command in Selenium IDE and select "Set / Clear Start Point"

2. Select the command in Selenium IDE and press "S" key on the keyboard

3. You can have only one start point

4. If you have already set one start point and you selected other command as start point. Then the

first start point will be removed and the new start point will be set.

How to execute a single line command from Selenium IDE? Selenium

Single line command from Selenium IDE can be executed in two ways

1. Right click on the command in Selenium IDE and select "Execute This Command"

2. Select the command in Selenium IDE and press "X" key on the keyboard.

Which are the browsers supported by Selenium IDE? | Selenium

Selenium IDE supports only one browser Mozilla Firefox.

The versions supported as of now are:

Mozilla Firefox 2.x

Mozilla Firefox 3.x

The versions not supported as of now are:

earlier versions of Mozilla Firefox 2.x

Mozilla Firefox 4.x.

What are the challenges with Selenium IDE? | Selenium

Selenium-IDE does not directly support:

1. condition statements

2. iteration or looping

3. logging and reporting of test results

4. error handling, particularly unexpected errors

5. database testing

6. test case grouping

7. re-execution of failed tests

8. test case dependency

196 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 197: General technical interview questions

9. capture screenshots on test failures

10. Results Report generations.

Read More!

What are the capabilities of Selenium IDE? | Selenium

Selenium IDE (Integrated Development Environment) works similar to commercial tools like QTP,

Silk Test and Test Partner etc.

 The below mentioned points describes well about Selenium IDE.

1. Selenium IDE is a Firefox add-on.

2. Selenium IDE can support recording the clicks, typing, and other actions to make a test cases.

3. Using Selenium IDE A Tester can play back the test cases in the Firefox browser

4. Selenium IDE supports exporting the test cases and suites to Selenium RC.

5. Debugging of the test cases with step-by-step can be done

6. breakpoint insertion is possible

7. Page abstraction functionality is supported by Selenium IDE

8. Selenium IDE can supports an extensibility capability allowing the use of add-ons or user

extensions that expand the functionality of Selenium IDE.

What are the test types supported by Selenium? | Selenium

Selenium could be used for testing the web based applications. The test types can be

supported are:

1. functional,

2. regression,

3. load testing 

The automation tool could be implemented for post release validation with continuous

integration tools like:

1. Jenkins,

2. Hudson,

3. QuickBuild

4. CruiseCont

What are the technical challenges with selenium? | Selenium

As you know Selenium is a free ware open source testing tool. There are many

challenges with Selenium.

197 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 198: General technical interview questions

1. Selenium Supports only web based applications

2. It doesn’t support any non web based (Like Win 32, Java Applet, Java Swing, .Net Client Server

etc) applications

3. When you compare selenium with QTP, Silk Test, Test Partner and RFT, there are many

challenges in terms of maintainability of the test cases

4. Since Selenium is a freeware tool, there is no direct support if one is in trouble with the support

of applications

5. There is no object repository concept in Selenium, so maintainability of the objects is very high

6. There are many challenges if one have to interact with Win 32 windows even when you are

working with Web based applications

7. Bitmap comparison is not supported by Selenium

8. Any reporting related capabilities, you need to depend on third party tools

9. You need to learn any one of the native language like (.Net, Java, Perl, Python, PHP, Ruby) to

work efficiently with the scripting side of selenium.

What do you know about Selenium? | selenium

Selenium is a suite of tools for web automation testing.

Selenium first came to life in 2004 when Jason Huggins was testing an internal application at

ThoughtWorks.

Selenium was a tremendous tool, it wasn’t without it’s drawbacks. Because of its Javascript based

automation engine and the security limitations browsers apply to Javascript, different things

became impossible to do. 

Selenium Suite of projects include:

Selenium IDE

Selenium Core

Selenium 1 (known as. Selenium RC or Remote Control)

Selenium 2 (known as. Selenium Webdriver)

Selenium-Grid.

What is difference between QTP and Selenium? | Selenium

 Only web applications can be testing using Selenium testing suite. However, QTP can be used for

testing client server applications. Selenium supports following web browsers: Internet Explorer,

Firefox, Safari, Opera or Konqueror on Windows, Mac OS X and Linux. However, QTP is limited to

Internet Explorer on Windows.

198 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 199: General technical interview questions

QTP uses scripting language implemented on top of VB Script. However, Selenium test suite has

the flexibility to use many languages like Java, .Net, Perl, PHP, Python, and Ruby.What are the advantages and disadvantages of using Selenium as testing tool? | Selenium

 Advantages: Free, Simple and powerful DOM (document object model) level testing, can be used

for continuous integration; great fit with Agile projects.

Disadvantages: Tricky setup; dreary errors diagnosis; can not test client server applications.What programming languages can you use in Selenium RC? | Selenium

 C#, Java, Perl, PHP, Python, Ruby.

What browsers are supported by Selenium Remote Control? | selenium

The test automation expert can use Firefox, IE 7/8, Safari and Opera browsers to run tests in

Selenium Remote Control.

What is the cost of Selenium test suite? selenium

 Selenium test suite a set of open source software tool, it is free of cost.What test can Selenium do? | Selenium

 Selenium is basically used for the functional testing of web based applications. It can be used for

testing in the continuous integration environment. It is also useful for agile testingWhat you say about the flexibility of Selenium test suite? | Selenium

 Selenium testing suite is highly flexible. There are multiple ways to add functionality to Selenium

framework to customize test automation. As compared to other test automation tools, it is

Selenium’s strongest characteristic. Selenium Remote Control support for multiple programming

and scripting languages allows the test automation engineer to build any logic they need into their

automated testing and to use a preferred programming or scripting language of one’s choice. Also,

the Selenium testing suite is an open source project where code can be modified and

enhancements can be submitted for contribution.How Selenium Grid works? | Selenium

Selenium Grid sent the tests to the hub. Then tests are redirected to an available Selenium RC,

which launch the browser and run the test. Thus, it allows for running tests in parallel with the

entire test suite.What is Selenium Grid? | Selenium

Selenium Grid in the selenium testing suit allows the Selenium RC solution to scale for test suites

that must be run in multiple environments. Selenium Grid can be used to run multiple instances of

Selenium RC on various operating system and browser configurations.What is Selenium RC (Remote Control)? | Selenium

 Selenium RC allows the test automation expert to use a programming language for maximum

flexibility and extensibility in developing test logic. For example, if the application under test

199 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 200: General technical interview questions

returns a result set and the automated test program needs to run tests on each element in the

result set, the iteration / loop support of programming language’s can be used to iterate through

the result set, calling Selenium commands to run tests on each item. Selenium RC provides an API

and library for each of its supported languages. This ability to use Selenium RC with a high level

programming language to develop test cases also allows the automated testing to be integrated

with the project’s automated build environment.What are the disadvantage of Selenium IDE tool? | Selenium

1. Selenium IDE tool can only be used in Mozilla Firefox browser. 

2. It is not playing multiple windows when we record it.

What are the advantage and features of Selenium IDE? | Selenium

1. Intelligent field selection will use IDs, names, or XPath as needed 

2. It is a record & playback tool and the script format can be written in various languages

including : C#, Java, PERL, Python, PHP, HTML 

3. Auto complete for all common Selenium commands 

4. Debug and set breakpoints 

5. Option to automatically assert the title of every page 

6. Support for Selenium user-extensions.js file.

Read More!

Can tests recorded using Selenium IDE be run in other browsers? | Selenium

 Yes. Although Selenium IDE is a Firefox add on, however, tests created in it can also be run in

other browsers by using Selenium RC (Selenium Remote Control) and specifying the name of the

test suite in command line.What is the use of context menu in Selenium IDE? | Selenium

 It allows the user to pick from a list of assertions and verifications for the selected location.What is Selenium IDE? | Selenium

 Selenium IDE is for building Selenium test cases. It operates as a Mozilla Firefox add on and

provides an easy to use interface for developing and running individual test cases or entire test

suites. Selenium-IDE has a recording feature, which will keep account of user actions as they are

performed and store them as a reusable script to play back.What are the main components of Selenium testing tools? | Selenium

 Selenium IDE, Selenium RC and Selenium Grid.

Read More!

What is Selenium? | Selenium

200 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 201: General technical interview questions

 Selenium is a set of tools that supports rapid development of test automation scripts for web

based applications. Selenium testing tools provides a rich set of testing functions specifically

designed to fulfil needs of testing of a web based application.

http://java-success.blogspot.in/2011/10/jmeter-interview-questions-and-answers.html

Q. What are some of the challenges you faced with JMeter?

If a subsequent request rely on the cookie set by the previous request, the "cookie manager"

element is required.

When setting up the "CSV Data Set Config", don't have any spaces in the variable names.

What are Pre-Processor and Post-Processor elements? In what order does JMeter

process various type of elements?

A Pre-Processor executes some action prior to a Sampler Request being made. If a Pre-Processor is

attached to a Sampler element, then it will execute just prior to that sampler element running. A

201 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 202: General technical interview questions

Pre-Processor is most often used to modify the settings of a Sample Request just before it runs, or

to update variables that aren't extracted from response text.

A Post-Processor executes some action after a Sampler Request has been made. If a Post-Processor

is attached to a Sampler element, then it will execute just after that sampler element runs. A Post-

Processor is most often used to process the response data, often to extract values from it.

A Regular Expression Extractor can be used as a Post-Processor element to extract values to be

used elsewhere in subsequent requests. For example, if you are using JSF and Seam frameworks,

the jsfViewState and CID values can be extracted as shown below:

202 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 203: General technical interview questions

The elements are executed in the following order as per the JMeter documentation.

0. Configuration elements

1. Pre-Processors

2. Timers

3. Sampler

4. Post-Processors (unless SampleResult is null)

5. Assertions (unless SampleResult is null)

6. Listeners (unless SampleResult is null)

Timers, Assertions, Pre- and Post-Processors are only processed if there is a sampler to which they

apply. Logic Controllers and Samplers are processed in the order in which they appear in the tree.

Other test elements are processed according to the scope in which they are found, and the type of

test element.

Q. How do you ensure re-usability in your JMeter scripts?

Using config elements like "CSV Data Set Config", "User Defined Variables", etc for greater data

reuse.

Modularizing shared tasks and invoking them via a "Module Controller".

Writing your own BeanShell functions, and reusing them.

1) What is Selenium IDE?Selenium IDE is an integrated development environment for Selenium tests. It is implemented as a Firefox extension, and has a recording feature, which will keep account of user actions as they are performed and store them as a reusable script to play back. Selenium-IDE also offers full editing of test cases for more precision and control.

2) Can Selenium test a application on iPhone’s Mobile Safari browser?Selenium can handle Mobile Safari browser. There is experimental Selenium IPhone Driver for running tests on Mobile with Safari on the iPhone and iPad and iPod Touch.

3) Can Selenium test an application on Android browser?Selenium can handle Android browser.

4) What tests can selenium do?Selenium could do functional, regression, and load of web based applications.

5) What are the disadvantages of Selenium?Disadvantages of Selenium:• Limitation in terms of browser support (It runs only in Mozilla).Scripts written using Selenium IDE can be used for other browsers only if it is used with Selenium RC or Selenium Core.• We can’t run recorded script if it is converted to Java, C#, Ruby etc.• Not allowed to write manual scripts like conditions and Loops for Data Driven Testing• There is no option to verify images.

203 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 204: General technical interview questions

6) What are the technical challenges with selenium?As you know Selenium is a free ware open source testing tool. There are many challenges with Selenium.1. Selenium supports only web based applications.2. It doesn’t support any non web based (Like Win 32, Java Applet, Java Swing, .Net Client Server etc) applications.3. When you compare selenium with QTP, Silk Test, Test Partner and RFT, there are many challenges in terms of maintainability of the test cases.4. Since Selenium is a freeware tool, there is no direct support if one is in trouble with the support of applications.5. There is no object repository concept in Selenium, so maintainability of the objects is very high6. There are many challenges if one have to interact with Win 32 windows even when you are working with Web based applications.7. Bitmap comparison is not supported by Selenium.8. Any reporting related capabilities, you need to depend on third party tools.9. You need to learn any one of the native language like (.Net, Java, Perl, Python, PHP, Ruby) to work efficiently with the scripting side of selenium.

7) How to run test case recorded using Selenium IDE in other browsers?Running test case recorded with the help of Selenium -Remote Control.

8) What is the selenium’s recording language?Selenium’s recording language is “HTML”.

9) What are the steps to run automation using selenium?The very basic steps are:1. Record the test steps using selenium-IDE.2. Modify the script according to the testing needs. Add validation points, Java Scripts, Time-out etc.3. Run the test.4. View the result after test run complete analyze.

10) What are the capabilities of Selenium IDE?Selenium IDE (Integrated Development Environment) works similar to commercial tools like QTP, Silk Test and Test Partner etc.The below points describes well about Selenium IDE.1. Selenium IDE is a Firefox add-on.2. Selenium IDE can support recording the clicks, typing, and other actions to make a test cases.3. Using Selenium IDE, a tester can play back the test cases in the Firefox browser.4. Selenium IDE supports exporting the test cases and suites to Selenium RC.5. Debugging of the test cases with step-by-step can be done.6. Breakpoint insertion is possible.7. Page abstraction functionality is supported by Selenium IDE.8. Selenium IDE can supports an extensibility capability allowing the use of add-ons or user extensions that expand the functionality of Selenium IDE.

11) What are the challenges with Selenium IDE?Selenium-IDE does not directly support:1. condition statements2. iteration or looping3. logging and reporting of test results4. error handling, particularly unexpected errors5. database testing6. test case grouping7. re-execution of failed tests8. test case dependency9. capture screenshots on test failures10. Results Report generations

12) How to execute a single line command from Selenium IDE?Single line command from Selenium IDE can be executed in two ways1. Right click on the command in Selenium IDE and select “Execute This Command”.2. Select the command in Selenium IDE and press “X” key on the keyboard.

204 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 205: General technical interview questions

13) What is Selenium Remote Control?Selenium-RC is the solution for tests that need more than simple browser actions and linear execution. We can use Selenium-RC whenever our test requires logic which is not supported by Selenium-IDE.Selenium-RC uses the full power of programming languages to create more complex tests like reading and writing files, querying a database, and emailing test results.

14) What are the advantages of Selenium?Advantages of Selenium:• It is a Open source.• Simple, Easy to install, Easy to work.• Selenium IDE is the only flavor of Selenium which allows you to record user action on browser window.• Can also record user actions in most of the popular languages like Java, C#, Perl, Ruby.• It will not record any operation that you do on your computer apart from the events on Firefox browser window.• During recording if you right click on any element it will show all the selenium commands available.• we can also edit existing command, by selecting it and editing on the boxes available.• we can also insert/delete commands by choosing appropriate option after right clicking.• Choose appropriate run option – i.e walk, run or test runner and review your results.

15) How to Use Selenium?We can use the selenium by selecting “Selenium IDE” from the Tools menu in Firefox.By default when the IDE comes up it has recording turned on. Go to a web site that you want to record, click on the record button and begin the browsing task(s). we will notice that as we click and type in the browser the IDE is recording everything we are doing. When we are done, simply end recording and click on the green arrow to play back the script you just created. Don’t forget to save your script before closing the IDE.

16) What are the Selenium components?There are three variants of Selenium, which can be used in isolation or in combination to create complete automation suite for the web applications. Each one has a specific role in aiding the development of web application test automation.• Selenium IDE• Selenium Core• Selenium RC

17) How to export the tests from Selenium IDE to Selenium RC in different languages?From selenium IDE, the test cases can be exported into the languages1. .Net,2. Java,3. Perl,4. Python,5. PHP,6. RubyThe below mentioned steps can explain how to export the test cases:1. Open the test case from Selenium IDE.2. Select File -> Export Test Case As.

18) How to insert a break point in Selenium IDE?Break point can be set in two ways in Selenium IDE:1. Right click on the command in Selenium IDE and select “Toggle Break Point”.2. Select the command in Selenium IDE and press “B” key on the keyboard.3. If you want to clear the break point once again press “B” key on the keyboard.4. You can set multiple break points in Selenium IDE.

19) How to insert a comment in Selenium IDE?Comments in Selenium IDE can be set in two ways.1. Right click on the command in Selenium IDE and select “Inert New Comment”.2. If you want to comment an existing line, we need to follow the below mentioned steps.a. Select the source tab in IDE.b. Select the line which you want to comment.

205 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 206: General technical interview questions

c. Assume that if you want to comment a open command you need to write like below mentioned code<tr><!–<td>open&l/td><td>/node/304/edit&l/td><td></td>–></tr>20) What is Selenium server default port number?Selenium server default port number is 4444.

21) How to run Selenium server, other than the default port 4444?We can run Selenium server on java -jar selenium-server.jar -port.

22) How do you check a single test method in multiple browser?We can check a single test method in multiple browsers by using Selenium Grid.

23) How do you identify an object using selenium?We can identify an object using selenium with:isElementPresent(String locator)isElementPresent takes a locator as the argument and if found returns a boolean value of True.

24) How do you handle Ajax controls using selenium?We can handle Ajax controls by using wait for condition command.

25) What is Selenium WebDriver or Google WebDriver or Selenium 2.0?WebDriver uses a different underlying framework from Selenium’s javascript Selenium-Core. It also provides an alternative API with functionality not supported in Selenium-RC. WebDriver does not depend on a javascript core embedded within the browser, therefore it is able to avoid some long-running Selenium limitations.WebDriver’s goal is to provide an API that establishes• A well-designed standard programming interface for web-app testing.• Improved consistency between browsers.• Additional functionality addressing testing problems not well-supported in Selenium 1.0.The Selenium developers strive to continuously improve Selenium. Integrating WebDriver is another step in that process. The developers of Selenium and of WebDriver felt they could make significant gains for the Open Source test automation community be combining forces and merging their ideas and technologies. Integrating WebDriver into Selenium is the current result of those efforts.

1.    What is Selenium?Selenium is a suite of tools for browser automation. It is composed of "IDE", a recording and playback mechanism, "WebDriver" and "RC" which provide APIs for browser automation in a wide variety of languages, and "Grid", which allows many tests using the APIs to be run in parallel. It works with most browsers, including Firefox from 3.0 up to 7, Internet Explorer 8, Google Chrome, Safari and Opera 11.5

2.    Describe technical problems that you had with Selenium tool?As with any other type of test automation tools like SilkTest, HP QTP, Watir, Canoo Webtest, Selenium allows to record, edit, and debug tests cases. However there are several problems that seriously affect maintainability of recorded test cases, occasionally Quality Assurance Engineers complain that it takes more time to maintain automated test cases than to perform manual testing; however this is an issue with all automated testing tools and most likely related to improper testing framework design. Another problem is complex ID for an HTML element. If IDs is auto-generated,

206 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 207: General technical interview questions

the recorder test cases may fail during playback. The work around is to use XPath to find required HTML element. Selenium supports AJAX without problems, but QA Tester should be aware that Selenium does not know when AJAX action is completed, so ClickAndWait will not work. Instead QA tester could use pause, but the snowballing effect of several 'pause' commands would really slow down total testing time of test cases. The best solution would be to use waitForElement.

3.    What test can Selenium do?Selenium could be used for the functional, regression, load testing of the web based applications. The automation tool could be implemented for post release validation with continuous integration tools like Jenkins, Hudson, QuickBuild or CruiseControl.

4.    What is the price of Selenium license per server?Selenium is open source software, released under the Apache 2.0 license and can be downloaded and used without charge.

5.    How much does Selenium license cost per client machine?Selenium is open source software, released under the Apache 2.0 license and can be downloaded and used without charge.

6.    Where to download Selenium?Selenium can be downloaded and installed for free from seleniumhq.org

7.    What is the latest version of Selenium?The latest versions are Selenium IDE 1.3.0, Selenium Server (formerly the Selenium RC Server) 2.8.0, Selenium Client Drivers Java 2.8.0, Selenium Client Drivers C# 2.8.0, Selenium Client Drivers Ruby 2.8.0, Selenium Client Drivers Python 2.8.1, Selenium Grid 1.0.8.

8.    What is Selenium IDE?Selenium IDE is a Firefox add-on that records clicks, typing, and other actions to make a test cases, which QA Tester can play back in the Firefox browser or export to Selenium RC. Selenium IDE has the following features: record/play feature, debugging with step-by-step and breakpoints, page abstraction functionality, an extensibility capability allowing the use of add-ons or user extensions that expand the functionality of Selenium IDE

9.    What are the limitations of Selenium IDE?Selenium IDE has many great features and is a fruitful and well-organized test automation tool for developing test cases, in the same time Selenium IDE is missing certain vital features of a testing tool: conditional statements, loops, logging functionality, exception handling, reporting functionality, database testing, re-execution of failed tests and screenshots taking capability. Selenium IDE doesn't for IE, Safari and Opera browsers.

10.    What does SIDE stand for?Selenium IDE. It was a very tricky interview question.

11.    What is Selenium Remote Control (RC) tool?Selenium Remote Control (RC) is the powerful solution for test cases that need more than simple browser actions and linear execution. Selenium-RC allows the developing of complex test scenarios like reading and writing files, querying a database, and emailing test reports. These tasks can be achieved by tweaking test cases in your preferred programming language.

12.    What are the advantages using Selenium as testing tool?If QA Tester would compare Selenium with HP QTP or Micro Focus SilkTest, QA Engineer would easily notice tremendous cost savings for Selenium. In contrast to expensive SilkTest license or QTP license, Selenium automation tool is absolutely free. It means that with almost no investment in purchasing tools, QA Team could easily build the state of the art test automation infrastructure. Selenium allows developing and executing test cases in various programming languages

207 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 208: General technical interview questions

including .NET, Java, Perl, RubyPython, PHP and even HTML. This is a great Selenium advantage, most likely your software developers already know how to develop and maintain C# or Java code, so they transfer coding techniques and best practices to QA team. Selenium allows simple and powerful DOM-level testing and in the same time could be used for testing in the traditional waterfall or modern Agile environments. Selenium would be definitely a great fit for the continuous integration tools Jenkins, Hudson, CruiseControl, because it could be installed on the server testing box, and controlled remotely from continuous integration build.

13.    What is Selenium Grid?Selenium Grid extends Selenium RC to distribute your tests across multiple servers, saving you time by running tests in parallel.

14.    What is Selenium WebDriver?Selenium WebDriver is a tool for writing automated tests of websites. It is an API name and aims to mimic the behaviour of a real user, and as such interacts with the HTML of the application. Selenium WebDriver is the successor of Selenium Remote Control which has been officially deprecated.

15.    How many browsers are supported by Selenium IDE?Test Engineer can record and playback test with Selenium IDE in Firefox.

16.    Can Selenium test an application on iPhone's Mobile Safari browser?Selenium should be able to handle Mobile Safari browser. There is experimental Selenium IPhone Driver for running tests on Mobile Safari on the iPhone, iPad and iPod Touch.

17.    Can Selenium test an application on Android browser?Selenium should be able to handle Android browser. There is experimental Selenium Android Driver for running tests in Android browser.

18.    What are the disadvantages of using Selenium as testing tool?Selenium weak points are tricky setup; dreary errors diagnosis; tests only web applications

19.    How many browsers are supported by Selenium Remote Control?QA Engineer can use Firefox 7, IE 8, Safari 5 and Opera 11.5 browsers to run actuall tests in Selenium RC.

20.    How many programming languages can you use in Selenium RC?Several programming languages are supported by Selenium Remote Control - C# Java Perl PHP Python Ruby

21.    How many testing framework can QA Tester use in Selenium RC?Testing frameworks aren't required, but they can be helpful if QA Tester wants to automate test cases. Selenium RC supports Bromine, JUnit, NUnit, RSpec (Ruby), Test::Unit (Ruby), TestNG (Java), unittest (Python).

22.    How to developer Selenium Test Cases?Using the Selenium IDE, QA Tester can record a test to comprehend the syntax of Selenium IDE commands, or to check the basic syntax for a specific type of user interface. Keep in mind that Selenium IDE recorder is not clever as QA Testers want it to be. Quality assurance team should never consider Selenium IDE as a "record, save, and run it" tool, all the time anticipate reworking a recorded test cases to make them maintainable in the future.

23.    What programming language is best for writing Selenium tests?The web applications may be written in Java, Ruby, PHP, Python or any other web framework. There are certain advantages for using the same language for writing test cases as application under test. For example, if the team already have the experience with Java, QA Tester could always

208 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 209: General technical interview questions

get the piece of advice while mastering Selenium test cases in Java. Sometimes it is better to choose simpler programming language that will ultimately deliver better success. In this case QA testers can adopt easier programming languages, for example Ruby, much faster comparing with Java, and can become become experts as soon as possible.

24.    Have you read any good books on Selenium?There are several great books covering Selenium automation tool, you could check the review at Best Selenium Books: Top Recommended page

25.    Do you know any alternative test automation tools for Selenium?Selenium appears to be the mainstream open source tool for browser side testing, but there are many alternatives. Canoo Webtest is a great Selenium alternative and it is probably the fastest automation tool. Another Selenium alternative is Watir, but in order to use Watir QA Tester has to learn Ruby. One more alternative to Selenium is Sahi, but is has confusing interface and small developers community.

26.    Compare HP QTP vs Selenium?When QA team considers acquiring test automation to assist in testing, one of the most critical decisions is what technologies or tools to use to automate the testing. The most obvious approach will be to look to the software market and evaluate a few test automation tools. Read Selenium vs QTP comparison

27.    Compare Borland Silktest vs Selenium?Check Selenium vs SilkTest comparison

28.    How to test Ajax application with SeleniumAjax interview questions could be tough for newbie in the test automation, but will be easily cracked by Selenium Tester with a relevant experience. Read the detailed approach at Testing Ajax applications with Selenium in the right way

29.    How can I learn to automate testing using Selenium?Don't be surprised if the interviewer asks you to describe the approach for learning Selenium. This interviewer wants to hear how you can innovative software test automation process the company. Most likely they are looking for software professional with a good Selenium experience, who can do Selenium training for team members and get the team started with test automation. I hope this Selenium tutorial will be helpful in the preparation for this Selenium interview question.

30. What are the main components of Selenium testing tools?Selenium IDE, Selenium RC and Selenium Grid

31. What is Selenium IDE?Selenium IDE is for building Selenium test cases. It operates as a Mozilla Firefox add on and provides an easy to use interface for developing and running individual test cases or entire test suites. Selenium-IDE has a recording feature, which will keep account of user actions as they are performed and store them as a reusable script to play back.

32. What is the use of context menu in Selenium IDE?It allows the user to pick from a list of assertions and verifications for the selected location.

33. Can tests recorded using Selenium IDE be run in other browsers?Yes. Although Selenium IDE is a Firefox add on, however, tests created in it can also be run in other browsers by using Selenium RC (Selenium Remote Control) and specifying the name of the test suite in command line.

34. What are the advantage and features of Selenium IDE?a. Intelligent field selection will use IDs, names, or XPath as needed

209 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 210: General technical interview questions

b. It is a record & playback tool and the script format can be written in various languages including C#, Java, PERL, Python, PHP, HTMLc. Auto complete for all common Selenium commandsd. Debug and set breakpointse. Option to automatically assert the title of every pagef. Support for Selenium user-extensions.js file

35. What are the disadvantage of Selenium IDE tool?a. Selenium IDE tool can only be used in Mozilla Firefox browser.b. It is not playing multiple windows when we record it.

36. What is Selenium RC (Remote Control)?Selenium RC allows the test automation expert to use a programming language for maximum flexibility and extensibility in developing test logic. For example, if the application under test returns a result set and the automated test program needs to run tests on each element in the result set, the iteration / loop support of programming language’s can be used to iterate through the result set, calling Selenium commands to run tests on each item. Selenium RC provides an API and library for each of its supported languages. This ability to use Selenium RC with a high level programming language to develop test cases also allows the automated testing to be integrated with the project’s automated build environment.

37. What is Selenium Grid?Selenium Grid in the selenium testing suit allows the Selenium RC solution to scale for test suites that must be run in multiple environments. Selenium Grid can be used to run multiple instances of Selenium RC on various operating system and browser configurations.

38. How Selenium Grid works?Selenium Grid sent the tests to the hub. Then tests are redirected to an available Selenium RC, which launch the browser and run the test. Thus, it allows for running tests in parallel with the entire test suite.

39. What you say about the flexibility of Selenium test suite?Selenium testing suite is highly flexible. There are multiple ways to add functionality to Selenium framework to customize test automation. As compared to other test automation tools, it is Selenium’s strongest characteristic. Selenium Remote Control support for multiple programming and scripting languages allows the test automation engineer to build any logic they need into their automated testing and to use a preferred programming or scripting language of one’s choice.

Also, the Selenium testing suite is an open source project where code can be modified and enhancements can be submitted for contribution.

40. What test can Selenium do?Selenium is basically used for the functional testing of web based applications. It can be used for testing in the continuous integration environment. It is also useful for agile testing

41. What is the cost of Selenium test suite?Selenium test suite a set of open source software tool, it is free of cost.

42. What browsers are supported by Selenium Remote Control?The test automation expert can use Firefox, IE 7/8, Safari and Opera browsers to run tests in Selenium Remote Control.

43. What programming languages can you use in Selenium RC?C#, Java, Perl, PHP, Python, Ruby

44. What are the advantages and disadvantages of using Selenium as testing tool?

210 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 211: General technical interview questions

Advantages: Free, Simple and powerful DOM (document object model) level testing, can be used for continuous integration; great fit with Agile projects.

Disadvantages: Tricky setup; dreary errors diagnosis; can not test client server applications.

45. What is difference between QTP and Selenium?Only web applications can be testing using Selenium testing suite. However, QTP can be used for testing client server applications. Selenium supports following web browsers: Internet Explorer,

Firefox, Safari, Opera or Konqueror on Windows, Mac OS X and Linux. However, QTP is limited to Internet Explorer on Windows.

QTP uses scripting language implemented on top of VB Script. However, Selenium test suite has the flexibility to use many languages like Java, .Net, Perl, PHP, Python, and Ruby.

46. What is difference between Borland Silk test and Selenium?Selenium is completely free test automation tool, while Silk Test is not. Only web applications can be testing using Selenium testing suite. However, Silk Test can be used for testing client server applications. Selenium supports following web browsers: Internet Explorer, Firefox, Safari, Opera or Konqueror on Windows, Mac OS X and Linux. However, Silk Test is limited to Internet Explorer and Firefox.

Silk Test uses 4Test scripting language. However, Selenium test suite has the flexibility to use many languages like Java, .Net, Perl, PHP, Python, and Ruby.

47. What is the difference between an assert and a verify with Selenium commands?Effectively an “assert” will fail the test and abort the current test case, whereas a “verify” will fail the test and continue to run the test case.  48. If a Selenium function requires a script argument, what would that argument look like in general terms?StoreEval(script, variable) and storeExpression(expression, variableName)

49. If a Selenium function requires a pattern argument, what five prefixes might that argument have?glob, regexp, exact, regexpi

50. What is the regular expression sequence that loosely translates to "anything or nothing?"(.* i.e., dot star) This two-character sequence can be translated as “0 or more occurrences of any character” or more simply, “anything or nothing.

51. What is the globbing sequence that loosely translates to "anything or nothing?(*) which translates to “match anything,” i.e., nothing, a single character, or many characters.

52. What does a character class for all alphabetic characters and digits look like in regular expressions?[0-9] matches any digit[A-Za-z0-9] matches any alphanumeric character[A-Za-z] matches any alphabet character

53. What does a character class for all alphabetic characters and digits look like in globbing?[0-9] matches any digit[a-zA-Z0-9] matches any alphanumeric character[a-zA-Z] matches any alphabet character

54. What must one set within SIDE in order to run a test from the beginning to a certain point

211 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 212: General technical interview questions

within the test?Set Toggle BreakPoint.

55. What does a right-pointing green triangle at the beginning of a command in SIDE indicate?Play Entire Test Suite

56. Which wildcards does SIDE support?*, [ ]

57. What are the four types of regular expression quantifiers which we've studied?Ans : * quantifier: 0 or more of the preceding character (or group)+ quantifier: 1 or more of the preceding character (or group)? quantifier: 0 or 1 of the preceding character (or group){1,5} quantifier: 1 through 5 of the preceding character (or group)

58. What regular expression special character(s) means "any character?"(.*)

59. What distinguishes between an absolute and relative URL in SIDE?Absolute URL: Its is base url and this represent domain address.Relative URL: (Absolute URL + Page Path).Open command uses Base URL (Absolute URL) to navigate web page.

60. How would one access a Selenium variable named "count" from within a JavaScript snippet?${count}

61. What Selenese command can be used to display the value of a variable in the log file, which can be very valuable for debugging?echo()

62. If one wanted to display the value of a variable named answer in the log file, what would the first argument to the previous command look like?echo()

63. Which Selenium command(s) simulates selecting a link?click, clickandWait, ClickAt, ClickAtandWait, DoubleClick, DoubleClickandWait, doubleClickAt, doubleClickAtandWait

64. Which two commands can be used to check that an alert with a particular message popped up?The following commands are available within Selenium for processing Alerts:• getAlert()• assertAlert()• assertAlertNotPresent()• assertAlertPresent()• storeAlert()• storeAlertPresent()• verifyAlert()• verifyAlertNotPresent()• verifyAlertPresent()• waitForAlert()• waitForAlertNotPresent()• waitForAlertPresent()The AlertPresent() and AlertNotPresent() functions check for the existence or not of an alert – regardless of it’s content. The Alert() functions allow the caller to specify a pattern which should be matched. The getAlert() method also exists in Selenium RC, and returns the text from the previous Alert displayed.

212 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 213: General technical interview questions

1. What do you know about Selenium?Selenium is a suite of tools for web automation testing. Selenium first came to life in 2004 when Jason Huggins was testing an internal application at Thought Works. Selenium was a tremendous tool, it wasn’t without its drawbacks. Because of its JavaScript based automation engine and the security limitations browsers apply to JavaScript, different things became impossible to do.Selenium Suite of projects includes:Selenium IDESelenium CoreSelenium 1 (known as Selenium RC or Remote Control)Selenium 2 (known as Selenium Web driver)Selenium-Grid 

2. What are the technical challenges with selenium?As you know Selenium is a free ware open source testing tool. There are many challenges with Selenium.

–>Selenium Supports only web based applications–>It doesn’t support any non web based (Like Win 32, Java Applet, Java Swing, .Net Client Server etc) applications–>When you compare selenium with QTP, Silk Test, Test Partner and RFT, there are many challenges in terms of maintainability of the test cases–>Since Selenium is a freeware tool, there is no direct support if one is in trouble with the support of applications–>There is no object repository concept in Selenium, so maintainability of the objects is very high–>There are many challenges if one have to interact with Win 32 windows even when you are working with Web based applications–>Bitmap comparison is not supported by Selenium–>Any reporting related capabilities, you need to depend on third party tools

213 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 214: General technical interview questions

–>You need to learn any one of the native language like (.Net, Java, Perl, Python, PHP, Ruby) to work efficiently with the scripting side of selenium

 

3. What are the test types supported by Selenium?Selenium could be used for testing the web based applications.

The test types can be supported are:1. Functional,2. Regression,3. Load testingThe automation tool could be implemented for post release validation with continuous integration tools like:1. Jenkins,2. Hudson,3. Quick Build4. CruiseCont 

4. What are the capabilities of Selenium IDE?Selenium IDE (Integrated Development Environment) works similar to commercial tools like QTP, Silk Test and Test Partner etc. The below mentioned points describes well about Selenium IDE.

1. Selenium IDE is a Firefox add-on.2. Selenium IDE can support recording the clicks, typing, and other actions to make a test cases.3. Using Selenium IDE A Tester can play back the test cases in the Firefox browser4. Selenium IDE supports exporting the test cases and suites to Selenium RC.5. debugging of the test cases with step-by-step can be done6. Breakpoint insertion is possible7. Page abstraction functionality is supported by Selenium IDE8. Selenium IDE can support an extensibility capability allowing the use of add-ons or user extensions that expand the functionality of Selenium IDE 

5. What are the challenges with Selenium IDE?Selenium-IDE does not directly support:

1. Condition statements2. Iteration or looping3. Logging and reporting of test results4. Error handling, particularly unexpected errors5. Database testing6. Test case grouping7. Re-execution of failed tests8. Test case dependency9. Capture screenshots on test failures10. Results Report generations 

6. Which are the browsers supported by Selenium IDE?Selenium IDE supports only one browser Mozilla Firefox. The versions supported as of now are:

Mozilla Firefox 2.xMozilla Firefox 3.x

214 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 215: General technical interview questions

The versions not supported as of now are:earlier versions of Mozilla Firefox 2.xMozilla Firefox 4.x 

7. How to execute a single line command from Selenium IDE?Single line command from Selenium IDE can be executed in two ways

1. Right click on the command in Selenium IDE and select “Execute This Command”2. Select the command in Selenium IDE and press “X” key on the keyboard 

8. How to insert a start point in Selenium IDE?Start point Selenium IDE can be set in two ways

1. Right click on the command in Selenium IDE and select “Set / Clear Start Point”2. Select the command in Selenium IDE and press “S” key on the keyboard3. You can have only one start point4. If you have already set one start point and you selected other command as start point. Then the first start point will be removed and the new start point will be set 

9. How to insert a comment in Selenium IDE?Comments in Selenium IDE can be set in two ways

1. Right click on the command in Selenium IDE and select “Inert New Comment”2. If you want to comment an existing line. You need to follow the below mentioned steps.a. Select the source tab in IDEb. Select the line which you want to commentc. Assume that if you want to comment a open command you need to write like below mentioned code<tr>

<!–

<td>open&l/td><td>/node/304/edit&l/td><td></td>–>

</tr>

 

10. How to insert a break point in Selenium IDE?Break point can be set in two ways in Selenium IDE

1. Right click on the command in Selenium IDE and select “Toggle Break Point”2. Select the command in Selenium IDE and press “B” key on the keyboard3. If you want to clear the break point once again Spress “B” key on the keyboard4. You can set multiple break points in Selenium IDE 

11. How to debug the tests in Selenium IDE?To debug or execute the test cases line by line. Follow the below mentioned steps

1. Insert a break From the location where you want to execute step by step2. Run the test case

215 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 216: General technical interview questions

3. Execution will be paused at the given break point4. Click on the step (Blue) button to continue with the next statement5. Click on Run button, to continue executing all the commands at a time 

12. How to export the tests from Selenium IDE to Selenium RC in different languages?From selenium IDE the test cases can be exported into the languages

1. .Net2. Java3. Perl4. Python5. PHP6. RubyThe below mentioned steps can explain how to export the test cases

1. Open the test case from Selenium IDE2. Select File -> Export Test Case As 

13. How to export Selenium IDE Test Suite to Selenium RC Suites?From selenium IDE the test suites can be exported into the languages as mentioned below

1. .Net2. Java3. Perl4. Python5. PHP6. RubyThe below mentioned steps can explain how to export the test suites

1. Open the test case from Selenium IDE2. Select File -> Export Test Suite As 

14. Which is the command used for displaying the values of a variable into the output console or log?The command used for displaying the values of a variable into the output console or log – echo

If you want to display a constant string. The below mentioned command can be usedecho <constant string>ex: echo “The sample message”If you want to display the value of a variable it can be written like belowecho ${<variable name>>ex: echo ${var1}

Note: Here var1 is the variable

 

15. Which are the browsers supported by Selenium RC?Supported browsers for Selenium RC include:

1. *firefox2. *mock3. *firefoxproxy4. *pifirefox

216 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 217: General technical interview questions

5. *chrome6. *iexploreproxy7. *iexplore8. *firefox39. *safariproxy10. *googlechrome11. *konqueror12. *firefox213. *safari14. *piiexplore15. *firefoxchrome16. *opera17. *iehta18. *custom 

16. Which are the Operating Systems supported by Selenium?Selenium IDEWorks in Firefox 2+ Start browser, run tests Run testsOperating Systems Supported:1. Windows,2. OS X3. Linux4. Solaris5. Others whichever supports Firefox 2+Selenium Remote ControlUsed for starting browser and run testsOperating Systems Supported:1. Windows,2. OS X3. Linux4. Solaris5. OthersSelenium CoreUsed for running testsOperating Systems Supported:1. Windows,2. OS X3. Linux4. Solaris5. Others 

17. What is Selenium RC?Selenium-RC is the solution for tests that need a little more than just simple browser actions and a linear execution. Selenium-RC leverages the full power of programming languages, creating tests that can do things like read and write external files, make queries to a database, send emails with test reports, and practically anything else a user can do with a normal application.

You will want to use Selenium-RC whenever your test requires logic not supported by running a script from Selenium-IDE

 

217 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 218: General technical interview questions

18. Why Selenium RC is used?Selenium-IDE does not directly support:

1. condition statements2. iteration3. logging and reporting of test results4. error handling, particularly unexpected errors5. database testing6. test case grouping7. re-execution of failed tests8. test case dependency9. capture screenshots on test failuresThe reason behind why Selenium-IDE does not support the above mentioned requirements is IDE supports only HTML language. Using HTML language we cannot achieve the above mentioned requirements. Because HTML does not support conditional, looping and external source connectives.

To overcome the above mentioned problems Selenium RC is used.

Since Selenium RC supports the languages .Net, Java, Perl, Python, PHP, and Ruby. In these languages we can write the programme to achieve the IDE issues

 

19. Which are the languages supported by Selenium RC?The languages supported by Selenium RC

1. .Net,2. Java (Junt 3, Junt 4, TestNG, Groovy)3. Perl,4. Python,5. PHP,6. Ruby 

20. What is Selenium Grid?Selenium Grid is part of Selenium suite of projects. Selenium Grid transparently distribute your tests on multiple machines so that you can run your tests in parallel, cutting down the time required for running in-browser test suites. This will dramatically speeds up in-browser web testing, giving you quick and accurate feedback you can rely on to improve your web application.

 

21. What is Selenium WebDriver or Google WebDriver or Selenium 2.0?WebDriver uses a different underlying framework from Selenium’s javascript Selenium-Core. It also provides an alternative API with functionality not supported in Selenium-RC. WebDriver does not depend on a javascript core embedded within the browser, therefore it is able to avoid some long-running Selenium limitations.

WebDriver’s goal is to provide an API that establishes• A well-designed standard programming interface for web-app testing.• Improved consistency between browsers.• Additional functionality addressing testing problems not well-supported in Selenium 1.0.The Selenium developers strive to continuously improve Selenium. Integrating WebDriver is another step in that process. The developers of Selenium and of WebDriver felt they could make significant gains for the Open Source test automation community be combining forces and merging

218 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 219: General technical interview questions

their ideas and technologies. Integrating WebDriver into Selenium is the current result of those efforts.

 

22. What are the capabilities of Selenium WebDriver or Google WebDriver or Selenium 2.0?One should use WebDriver when requiring improved support for

• Mult-browser testing including improved functionality for browsers not well-supported by Selenium-1.0.• Handling multiple frames, multiple browser windows, popups, and alerts.• Page navigation.• Drag-and-drop.• AJAX-based UI elements. 

23. What is the architecture of Selenium RC?The Selenium Server which launches and kills browsers, and acts as an HTTP proxy for browser requests.

Client libraries for various programming languages, each of which instructs the Selenium Server in how to test the AUT by passing it your test script’s Selenium commands.

The diagram shows the client libraries communicate with the Server passing each Selenium command for execution. Then the server passes the Selenium command to the browser using Selenium-Core JavaScript commands. The browser, using its JavaScript interpreter, executes the Selenium command, which effectively, runs the check you specified in your Selenese test script.

 

24. What is the architecture of Selenium Grid?The below mentioned theory explains about the setup of Selenium Grid with architecture and how it works.Selenium Grid builds on the traditional Selenium setup, taking advantage of the following properties:

* The Selenium test, the application under test, and the remote control/browser pair do not have to be co-located. They communicate through HTTP, so they can all live on different machines.* The Selenium tests and the web application under test are obviously specific to a particular project. Nevertheless, neither the Selenium remote control nor the browser is tied to a specific application. As a matter of fact, they provide a capacity that can easily be shared by multiple applications and multiple projects.Consequently, if only we could build a distributed grid of Selenium Remote Controls, we could easily share it across builds, applications, projects – even potentially across organizations. Of course we would also need to address the scalability issues as described earlier when covering the traditional Selenium setup. This is why we need a component in charge of:

* Allocating a Selenium Remote Control to a specific test (transparently)* Limiting the number of concurrent test runs on each Remote Control* Shielding the tests from the actual grid infrastructureSelenium Grid calls this component the Selenium Hub.

* The Hub exposes an external interface that is exactly the same as the one of a traditional Remote Control. This means that a test suite can transparently target a regular Remote Control or a Selenium Hub with no code change. It just needs to target a different IP address. This is important

219 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 220: General technical interview questions

as it shields the tests from the grid infrastructure (which you can scale transparently). This also makes the developer’s life easier. The same test can be run locally on a developer machine, or run on a heavy duty distributed grid as part of a build – without ever changing a line of code.* The Hub allocates Selenium Remote Controls to each test. The Hub is also in charge of routing the Selenese requests from the tests to the appropriate Remote Control as well as keeping track of testing sessions.* When a new test starts, the Hub puts its first request on hold if there is no available Remote Control in the grid providing the appropriate capabilities. As soon as a suitable Remote Control becomes available, the Hub will serve the request. For the whole time, the tests do not have to be aware of what is happening within the grid; it is just waiting for an HTTP response to come back. 

25. Does Selenium support mobile internet testing?Selenium supports Opera. And opera is used in most of the Smart phones. So whichever Smart phone supports opera, selenium can be used to test. So, one can use Selenium RC to run the tests on mobiles.

 

26. Does Selenium support Google Android Operating System?Yes, Selenium Web Driver or Google Web Driver or Selenium 2.0 supports Android Operating System. There are several libraries written to support Android Operating System.

 

27. What are the types of text patterns available in Selenium?There are three types of patterns available in Selenium1. globbing2. regular expressions3. exact 

28. How to use regular expressions in Selenium?Regular expressions in Selenium IDE can be used with the keyword – regexp: as a prefix to the value and patterns needs to be included for the expected values.For example if you want to use the regular expression for a commandCommand: verifyTextTarget: //font/font/b/font[1]Value: Flight Confirmation # 2011-05-02451in the above example Flight Confirmation is continuously changing each time you run the test case. So this can be written with a regular expression as mentioned below

Command: verifyTextTarget: //font/font/b/font[1]Value: regexp:Flight Confirmation # [0-9]{4}-[0-9]{2}-[0-9]{5,10} 

29. What are the regular expression patterns available in Selenium?Selenium regular expression patterns offer the same wide array of special characters that exist in JavaScript. Below are a subset of those special characters

PATTERN MATCH

. any single character

[ ] character class: any single character that appears inside the brackets

220 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 221: General technical interview questions

PATTERN MATCH

* quantifier: 0 or more of the preceding character (or group)

+ quantifier: 1 or more of the preceding character (or group)

? quantifier: 0 or 1 of the preceding character (or group)

{1,5} quantifier: 1 through 5 of the preceding character (or group)

| alternation: the character/group on the left or the character/group on the right

( ) grouping: often used with alternation and/or quantifier

 

30. What is Selenese?Selenium set of commands which are used for running the test are called as Selenese.There are three types of Selenese, those are:1. Actions – used for performing the operations and interactions with the target elements2. Assertions – used as check points3. Accessors – used for storing the values in a variable 

31. How do you add check points or verification points in Selenium?check points or verification points are known as Assertions in Selenium. The keywords with below mentioned prefix will be used for adding check points or verification points.

1. verify2. assert3. waitFor 

32. What is Assertion in Selenium?Assertion is nothing but a check or verification point.

Assertion verifies the state of the application conforms to what is expected.Examples include “make sure the page title is X” and “verify that this checkbox is checked. 

33. What are the types of Assertions there in Selenium?Selenium Assertions can be used in 3 modes:

1) assert – When an “assert” fails, the test will be aborted. If you are executing test suite, the next state case will start

2) verify – When a “verify” fails, the test will continue execution, logging the failure.

3) waitFor – “waitFor” commands wait for some condition to become true (which can be useful for testing Ajax applications). They will succeed immediately if the condition is already true. However, they will fail and halt the test if the condition does not become true within the current timeout setting

 

34. When to use Assert, Verify and WaitFor in Selenium?1) assert – If the expected value is mandatory to continue with the next set of steps we will use Assert. As Assert aborts the test, if the expected value doesn’t match. It is good to use for any mandatory checks.

221 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 222: General technical interview questions

2) verify – If the expected value is optional to continue with the next set of steps we will use Verify. As Verify continues executing with the next set of steps, if the expected value doesn’t match. It is good to use for any optional checks.

3) waitFor – If your test needs to wait, if the expected value is not matching we use waitFor. We normally use waitFor for AJAX kind of controls loading within a page

 

35. What is an Accessor in Selenium?Accessor is one of the type of Selenese.

I. Accessors are used for storing the value of a target in a variable.

Ex:1) storeTitle – Stores the title of a window in a variable2) storeText – Stores the target element text in a variable

II. Accessors are also used for evaluating the result and storing the result in a variable

Ex: storeTextPresent – Evaluates whether the text is present in the current window. If the text is present stores true in the variable else stores false

Ex: storeEementPresent – Evaluates whether the element is present in the current window. If the element is present stores true in the variable else stores false

 

36. When to use Accessors in Selenium?Accessors are mostly used for storing the value in a variable.

The variable can be used for following reasons:

1) To get the value from an element and comparing with some dynamic value

2) To take a logical decision to execute the test stepsex: if the value of the variable true execute step1 and step2 else step3 and step43) To execute some statements in a loop based on the value returned by the element

 

37. How to capture bitmaps in Selenium?Bitmaps are captured using the Selenium set of commands. There are two modes of capturing the bitmaps

1) Capture the bitmap for the entire page – it captures the browser main page area of AUT2) Capture the bitmap for the screen shots – it captures the entire screen shot like the print scree that you give from your keyboardSelenium doesn’t support bitmap capturing for an element on AUT.

 

38. Which are the commands used for capturing the bitmaps?captureEntirePageScreenshotSaves the entire contents of the current window canvas to a PNG file. Contrast this with the captureScreenshot command, which captures the contents of the OS viewport (i.e. whatever is currently being displayed on the monitor), and is implemented in the RC only. Currently this only works in Firefox when running in chrome mode, and in IE non-HTA using the EXPERIMENTAL

222 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 223: General technical interview questions

“Snapsie” utility. The Firefox implementation is mostly borrowed from the Screengrab! Firefox extension. captureEntirePageScreenshotAndWaitSaves the entire contents of the current window canvas to a PNG file. Contrast this with the captureScreenshot command, which captures the contents of the OS viewport (i.e. whatever is currently being displayed on the monitor), and is implemented in the RC only. Currently this only works in Firefox when running in chrome mode, and in IE non-HTA using the EXPERIMENTAL “Snapsie” utility. The Firefox implementation is mostly borrowed from the Screengrab! Firefox extension. Please seecaptureEntirePageScreenshotAndWait for details.Note: This command runs with only mozilla firefox when you run the tests from RC. Other browsers it will not support 

39. What is the difference between captureEntirePageScreenshot and CaptureScreenShot?captureEntirePageScreenshot1. This captures the AUT web page only2. This supports only mozilla firefox3. Accepts two arguments. one is the file name to be saved and other argument is back ground colorCaptureScreenShot

1. This captures the System screen shot2. This supports all the browsers when you run from Selenium RC3. Accepts one argument. That is the file name to be saved. 

40. How do you set user extensions in Selenium IDE?1. Open user-extensions.js with an editor (Notepad, etc.); it’s found in the selenium\core\scripts folder. If it doesn’t exist, just create it.2. If you need to, commit the user-extensions.js file (like if you use subversion).3. Open Selenium IDE and choose the Options menu and then Options… from that menu.4. Make sure the path to your user-extensions.js file is entered in the Selenium Core extensions field (like \selenium\core\scripts\user-extensions.js)5. Press OK button on options6. Restart the IDE to reflect your extensions.Note: After reopen, Selenium IDE may show compilations errors if the user-extensions.js file has any syntax errors. 

41. What are the limitations of Selenium IDEThe limitations of Selenium IDE are:

1) Selenium IDE uses only HTML language2) Conditional or branching statements execution like using of if, select statements is not possible3) Looping statements using is not possible directly in Selenium HTML language in ide4) Reading from external files like .txt, .xls is not possible5) Reading from the external databases is not possible with ide6) Exceptional handling is not there7) A neat formatted Reporting is not possible with ideTo eliminate the above issues we use Selenium RC

1) What is Selenium IDE?

223 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 224: General technical interview questions

Selenium IDE is an integrated development environment for Selenium tests. It is implemented as a

Firefox extension, and has a recording feature, which will keep account of user actions as they are

performed and store them as a reusable script to play back. Selenium-IDE also offers full editing of

test cases for more precision and control.

2) Can Selenium test a application on iPhone’s Mobile Safari browser?

Selenium can handle Mobile Safari browser. There is experimental Selenium IPhone Driver for

running tests on Mobile with Safari on the iPhone and iPad and iPod Touch.

3) Can Selenium test an application on Android browser?

Selenium can handle Android browser.

4) What tests can selenium do?

Selenium could do functional, regression, and load of web based applications.

5) What are the disadvantages of Selenium?

Disadvantages of Selenium:

• Limitation in terms of browser support (It runs only in Mozilla). Scripts written using Selenium IDE

can be used for other browsers only if it is used with Selenium RC or Selenium Core.

• We can’t run recorded script if it is converted to Java, C#, Ruby etc.

• Not allowed to write manual scripts like conditions and Loops for Data Driven Testing

• There is no option to verify images.

6) What are the technical challenges with selenium?

As you know Selenium is a free ware open source testing tool. There are many challenges with

Selenium.

1. Selenium supports only web based applications.

2. It doesn’t support any non web based (Like Win 32, Java Applet, Java Swing, .Net Client Server

etc) applications.

3. When you compare selenium with QTP, Silk Test, Test Partner and RFT, there are many

challenges in terms of maintainability of the test cases.

4. Since Selenium is a freeware tool, there is no direct support if one is in trouble with the support

of applications.

5. There is no object repository concept in Selenium, so maintainability of the objects is very high

6. There are many challenges if one have to interact with Win 32 windows even when you are

working with Web based applications.

7. Bitmap comparison is not supported by Selenium.

8. Any reporting related capabilities, you need to depend on third party tools.

9. You need to learn any one of the native language like (.Net, Java, Perl, Python, PHP, Ruby) to

work efficiently with the scripting side of selenium.

7) How to run test case recorded using Selenium IDE in other browsers?

Running test case recorded with the help of Selenium -Remote Control.

8) What is the selenium’s recording language?

Selenium’s recording language is “HTML”.

9) What are the steps to run automation using selenium?

The very basic steps are:

1. Record the test steps using selenium-IDE.

2. Modify the script according to the testing needs. Add validation points, Java Scripts, Time-out

etc.

3. Run the test.

4. View the result after test run complete analyze.

224 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 225: General technical interview questions

10) What are the capabilities of Selenium IDE?

Selenium IDE (Integrated Development Environment) works similar to commercial tools like QTP,

Silk Test and Test Partner etc.

The below points describes well about Selenium IDE.

1. Selenium IDE is a Firefox add-on.

2. Selenium IDE can support recording the clicks, typing, and other actions to make a test cases.

3. Using Selenium IDE, a tester can play back the test cases in the Firefox browser.

4. Selenium IDE supports exporting the test cases and suites to Selenium RC.

5. debugging of the test cases with step-by-step can be done.

6. Breakpoint insertion is possible.

7. Page abstraction functionality is supported by Selenium IDE.

8. Selenium IDE can supports an extensibility capability allowing the use of add-ons or user

extensions that expand the functionality of Selenium IDE.

1.      What are the advantages and disadvantages of Selenium IDE?

Advantages:

It is Opensource

Can generate code in any format like java,python,html,php etc.

Easy to record and play

Can extend the code of IDE using user-extensions

Can increase and decrease the speed of execution

Can run multiple tests at a time

Breakpoint insertion is possible

Disadvantages:

Supports only in Mozilla as add-on,but not for IE,chrome etc

Doesn’t support flow control,data driven testing unless we use third party user-extensions.

Not efficient in running large number of scripts,complex to manage suites.

Detailed results are not available

Supports only web based apps

2.      What is the Difference between id and name?

name as used on the form controls (input, textarea, select, button elements) is radically different

from the id attribute on named elements. In this case, the name attribute relates to how data is

labeled when sent to server, and multiple elements may share the same name. The id attribute on

the other hand is for identifying one unique element for the purposes of scripting, styling, or

addressing.

id and name are the two different attributes of web elements.These are used to locate the element

on webpage while automating,most of the times id is used, if two elements has same id’s then we

can also look for name attribute to locate exact one.

Ex:       //input[@id =”xxx” and @name =”yyy”]

//input[@id=”xxx”]

//input[@name=”yyy”]

3.      What is the difference between Xpath and dom?

DOM: The Document Object Model (DOM) is a cross-platform and language-independent

convention for representing and interacting

withobjects in HTML, XHTML and XML documents. Objects in the DOM tree may be addressed and

manipulated by using methods on the objects

225 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]

Page 226: General technical interview questions

Ex: var element=document.getElementById("intro");

XPTAH: XPath, the XML Path Language, is a query language for selecting nodes from

an XML document. In addition, XPath may be used to compute values (e.g., strings, numbers,

or Boolean values) from the content of an XML document.

Ex: //input[@id=”xxx”]

4.      What is the difference between assert and verify command?

Assert : If you use this, the test will be terminated at the point where check fails. The main plus

point of this is you can immediately see if the test passed or failed. However, the disadvantage of

doing this is the remaining checks and verification that will never be performed and you can not

track that.

Verify : This is in contrast, will not terminate the whole test. If you only used Verify commands in

your tests, all tests are going to run guaranteed even if any of the checks fails when test is

running. However, there is a bit of work in order to find out your results in details

5.      What type of testing we can do by using Selenium? Functional automation testing of web applications(Android also) Load testing

226 | P a g eQA Keval Shah Site: shahkeval.wordpress.com+919624928454 Email ID: [email protected]