Best Blogger Template

Archive for 10/01/2010 - 11/01/2010


Mainframe Questions

Q1) Name the divisions in a COBOL program ?.

A1) IDENTIFICATION DIVISION, ENVIRONMENT DIVISION, DATA DIVISION, PROCEDURE DIVISION.



Q2) What are the different data types available in COBOL?

A2) Alpha-numeric (X), alphabetic (A) and numeric (9).



Q3) What does the INITIALIZE verb do? - GS

A3) Alphabetic, Alphanumeric fields & alphanumeric edited items are set to SPACES. Numeric, Numeric edited items set to ZERO. FILLER , OCCURS DEPENDING ON items left untouched.



Q4) What is 77 level used for ?

A4) Elementary level item. Cannot be subdivisions of other items (cannot be qualified), nor can they be subdivided themselves.



Q5) What is 88 level used for ?

A5) For condition names.



Q6) What is level 66 used for ?

A6) For RENAMES clause.



Q7) What does the IS NUMERIC clause establish ?

A7) IS NUMERIC can be used on alphanumeric items, signed numeric & packed decimal items and unsigned numeric & packed decimal items. IS NUMERIC returns TRUE if the item only consists of 0-9. However, if the item being tested is a signed item, then it may contain 0-9, + and - .



Q8) How do you define a table/array in COBOL?

A8) ARRAYS.

05 ARRAY1 PIC X(9) OCCURS 10 TIMES.

05 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX.



Q9) Can the OCCURS clause be at the 01 level?

A9) No.



Q10) What is the difference between index and subscript? - GS

A10) Subscript refers to the array occurrence while index is the displacement (in no of bytes) from the beginning of the

array. An index can only be modified using PERFORM, SEARCH & SET. Need to have index for a table in order to

use SEARCH, SEARCH ALL.



Q11) What is the difference between SEARCH and SEARCH ALL? - GS

A11) SEARCH - is a serial search.

SEARCH ALL - is a binary search & the table must be sorted ( ASCENDING/DESCENDING KEY clause to be used & data loaded in this order) before using SEARCH ALL.



Q12) What should be the sorting order for SEARCH ALL? - GS

A12) It can be either ASCENDING or DESCENDING. ASCENDING is default. If you want the search to be done on an

array sorted in descending order, then while defining the array, you should give DESCENDING KEY clause. (You

must load the table in the specified order).



Q13) What is binary search?

A13) Search on a sorted array. Compare the item to be searched with the item at the center. If it matches, fine else repeat the process with the left half or the right half depending on where the item lies.



Q14) My program has an array defined to have 10 items. Due to a bug, I find that even if the program access the

11th item in this array, the program does not abend. What is wrong with it?

A14) Must use compiler option SSRANGE if you want array bounds checking. Default is NOSSRANGE.



Q15) How do you sort in a COBOL program? Give sort file definition, sort statement syntax and meaning. - GS

A15) Syntax: SORT file-1 ON ASCENDING/DESCENDING KEY key.... USING file-2 GIVING file-3.



USING can be substituted by INPUT PROCEDURE IS para-1 THRU para-2

GIVING can be substituted by OUTPUT PROCEDURE IS para-1 THRU para-2.



file-1 is the sort (work) file and must be described using SD entry in FILE SECTION.

file-2 is the input file for the SORT and must be described using an FD entry in FILE SECTION and SELECT

clause in FILE CONTROL.

file-3 is the out file from the SORT and must be described using an FD entry in FILE SECTION and SELECT

clause in FILE CONTROL.

file-1, file-2 & file-3 should not be opened explicitly.



INPUT PROCEDURE is executed before the sort and records must be RELEASEd to the sort work file from the input procedure.

OUTPUT PROCEDURE is executed after all records have been sorted. Records from the sort work file must be RETURNed one at a time to the output procedure.



Q16) How do you define a sort file in JCL that runs the COBOL program?

A16) Use the SORTWK01, SORTWK02,..... dd names in the step. Number of sort datasets depends on the volume of data

being sorted, but a minimum of 3 is required.



Q17) What is the difference between performing a SECTION and a PARAGRAPH? - GS

A17) Performing a SECTION will cause all the paragraphs that are part of the section, to be performed.

Performing a PARAGRAPH will cause only that paragraph to be performed.



Q18) What is the use of EVALUATE statement? - GS

A18) Evaluate is like a case statement and can be used to replace nested Ifs. The difference between EVALUATE and

case is that no 'break' is required for EVALUATE i.e. control comes out of the EVALUATE as soon as one match is

made.



Q19) What are the different forms of EVALUATE statement?

A19)

EVALUATE EVALUATE SQLCODE ALSO FILE-STATUS

WHEN A=B AND C=D WHEN 100 ALSO '00'

imperative stmt imperative stmt

WHEN (D+X)/Y = 4 WHEN -305 ALSO '32'

imperative stmt imperative stmt

WHEN OTHER WHEN OTHER

imperative stmt imperative stmt

END-EVALUATE END-EVALUATE



EVALUATE SQLCODE ALSO A=B EVALUATE SQLCODE ALSO TRUE

WHEN 100 ALSO TRUE WHEN 100 ALSO A=B

imperative stmt imperative stmt

WHEN -305 ALSO FALSE WHEN -305 ALSO (A/C=4)

imperative stmt imperative stmt

END-EVALUATE END-EVALUATE



Q20) How do you come out of an EVALUATE statement? - GS

A20) After the execution of one of the when clauses, the control is automatically passed on to the next sentence after the

EVALUATE statement. There is no need of any extra code.



Q21) In an EVALUATE statement, can I give a complex condition on a when clause?

A21) Yes.



Q22) What is a scope terminator? Give examples.

A22) Scope terminator is used to mark the end of a verb e.g. EVALUATE, END-EVALUATE; IF, END-IF.



Q23) How do you do in-line PERFORM? - GS

A23) PERFORM ... ...



END-PERFORM



Q24) When would you use in-line perform?

A24) When the body of the perform will not be used in other paragraphs. If the body of the perform is a generic type of code

(used from various other places in the program), it would be better to put the code in a separate Para and use

PERFORM Para name rather than in-line perform.



Q25) What is the difference between CONTINUE & NEXT SENTENCE ?

A25) They appear to be similar, that is, the control goes to the next sentence in the paragraph. But, Next Sentence would

take the control to the sentence after it finds a full stop (.). Check out by writing the following code example, one if

sentence followed by 3 display statements (sorry they appear one line here because of formatting restrictions) If 1 > 0

then next sentence end if display 'line 1' display 'line 2'. display 'line 3'. *** Note- there is a dot (.) only at the end of

the last 2 statements, see the effect by replacing Next Sentence with Continue ***



Q26) What does EXIT do ?

A26) Does nothing ! If used, must be the only sentence within a paragraph.



Q27) Can I redefine an X(100) field with a field of X(200)?

A27) Yes. Redefines just causes both fields to start at the same location. For example:



01 WS-TOP PIC X(1)

01 WS-TOP-RED REDEFINES WS-TOP PIC X(2).

If you MOVE '12' to WS-TOP-RED,

DISPLAY WS-TOP will show 1 while

DISPLAY WS-TOP-RED will show 12.



Q28) Can I redefine an X(200) field with a field of X(100) ?

A31) Yes.



Q31) What do you do to resolve SOC-7 error? - GS

A31) Basically you need to correcting the offending data. Many times the reason for SOC7 is an un-initialized numeric item.

Examine that possibility first. Many installations provide you a dump for run time abend’s ( it can be generated also

by calling some subroutines or OS services thru assembly language). These dumps provide the offset of the last

instruction at which the abend occurred. Examine the compilation output XREF listing to get the verb and the line

number of the source code at this offset. Then you can look at the source code to find the bug. To get capture the

runtime dumps, you will have to define some datasets (SYSABOUT etc ) in the JCL. If none of these are helpful, use

judgement and DISPLAY to localize the source of error. Some installation might have batch program debugging

tools. Use them.



Q32) How is sign stored in Packed Decimal fields and Zoned Decimal fields?

A32) Packed Decimal fields: Sign is stored as a hex value in the last nibble (4 bits ) of the storage.

Zoned Decimal fields: As a default, sign is over punched with the numeric value stored in the last bite.



Q33) How is sign stored in a comp-3 field? - GS

A33) It is stored in the last nibble. For example if your number is +100, it stores hex 0C in the last byte, hex 1C if

your number is 101, hex 2C if your number is 102, hex 1D if the number is -101, hex 2D if the number is –102 etc...



Q34) How is sign stored in a COMP field ? - GS

A34) In the most significant bit. Bit is ON if -ve, OFF if +ve.



Q35) What is the difference between COMP & COMP-3 ?

A35) COMP is a binary storage format while COMP-3 is packed decimal format.



Q36) What is COMP-1? COMP-2?

A36) COMP-1 - Single precision floating point. Uses 4 bytes.

COMP-2 - Double precision floating point. Uses 8 bytes.



Q37) How do you define a variable of COMP-1? COMP-2?

A37) No picture clause to be given. Example 01 WS-VAR USAGE COMP-1.



Q38) How many bytes does a S9(7) COMP-3 field occupy ?

A38) Will take 4 bytes. Sign is stored as hex value in the last nibble. General formula is INT((n/2) + 1)), where n=7 in this

example.



Q39) How many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy ?

A39) Will occupy 8 bytes (one extra byte for sign).



Q40) How many bytes will a S9(8) COMP field occupy ?

A40) 4 bytes.



Q41) What is the maximum value that can be stored in S9(8) COMP?

A41) 99999999



Q42) What is COMP SYNC?

A42) Causes the item to be aligned on natural boundaries. Can be SYNCHRONIZED LEFT or RIGHT. For binary data

items, the address resolution is faster if they are located at word boundaries in the memory. For example, on main

frame the memory word size is 4 bytes. This means that each word will start from an address divisible by 4. If my

first variable is x(3) and next one is s9(4) comp, then if you do not specify the SYNC clause, S9(4) COMP will start

from byte 3 ( assuming that it starts from 0 ). If you specify SYNC, then the binary data item will start from address 4.

You might see some wastage of memory, but the access to this computational field is faster.



Q43) What is the maximum size of a 01 level item in COBOL I? in COBOL II?

A43) In COBOL II: 16777215



Q44) How do you reference the following file formats from COBOL programs:

A44)

Fixed Block File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F,

BLOCK CONTAINS 0 .

Fixed Unblocked - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F,

do not use BLOCK CONTAINS

Variable Block File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V, BLOCK

CONTAINS 0. Do not code the 4 bytes for record length in FD ie JCL rec length will be max rec length in pgm + 4

Variable Unblocked - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V, do not use

BLOCK CONTAINS. Do not code 4 bytes for record length in FD ie JCL rec length will

be max rec length in pgm + 4.

ESDS VSAM file - Use ORGANISATION IS SEQUENTIAL.

KSDS VSAM file - Use ORGANISATION IS INDEXED, RECORD KEY IS, ALTERNATE RECORD KEY IS RRDS File - Use ORGANISATION IS RELATIVE, RELATIVE KEY IS

Printer File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK

CONTAINS 0. (Use RECFM=FBA in JCL DCB).



Q45) What are different file OPEN modes available in COBOL?

A45) Open for INPUT, OUTPUT, I-O, EXTEND.



Q46) What is the mode in which you will OPEN a file for writing? - GS

A46) OUTPUT, EXTEND



Q47) In the JCL, how do you define the files referred to in a subroutine ?

A47) Supply the DD cards just as you would for files referred to in the main program.



Q48) Can you REWRITE a record in an ESDS file? Can you DELETE a record from it?

A48) Can rewrite (record length must be same), but not delete.



Q49) What is file status 92? - GS

A49) Logic error. e.g., a file is opened for input and an attempt is made to write to it.



Q50) What is file status 39 ?

A50) Mismatch in LRECL or BLOCKSIZE or RECFM between your COBOL pgm & the JCL (or the dataset label). You

will get file status 39 on an OPEN.



Q51) What is Static and Dynamic linking ?

A51) In static linking, the called subroutine is link-edited into the calling program , while in dynamic linking, the subroutine

& the main program will exist as separate load modules. You choose static/dynamic linking by choosing either the

DYNAM or NODYNAM link edit option. (Even if you choose NODYNAM, a CALL identifier (as opposed to a

CALL literal), will translate to a DYNAMIC call).

A statically called subroutine will not be in its initial state the next time it is called unless you explicitly use INITIAL

or you do a CANCEL. A dynamically called routine will always be in its initial state.





Q52) What is AMODE(24), AMODE(31), RMODE(24) and RMODE(ANY)? (applicable to only MVS/ESA

Enterprise Server).

A52) These are compile/link edit options. Basically AMODE stands for Addressing mode and RMODE for Residency

mode.

AMODE(24) - 24 bit addressing;

AMODE(31) - 31 bit addressing

AMODE(ANY) - Either 24 bit or 31 bit addressing depending on RMODE.

RMODE(24) - Resides in virtual storage below 16 Meg line. Use this for 31 bit programs that call 24 bit programs.

(OS/VS Cobol pgms use 24 bit addresses only).

RMODE(ANY) - Can reside above or below 16 Meg line.



Q53) What compiler option would you use for dynamic linking?

A53) DYNAM.



Q54) What is SSRANGE, NOSSRANGE ?

A54) These are compiler options with respect to subscript out of range checking. NOSSRANGE is the default and if chosen,

no run time error will be flagged if your index or subscript goes out of the permissible range.



Q55) How do you set a return code to the JCL from a COBOL program?

A55) Move a value to RETURN-CODE register. RETURN-CODE should not be declared in your program.



Q56) How can you submit a job from COBOL programs?

A56) Write JCL cards to a dataset with //xxxxxxx SYSOUT= (A,INTRDR) where 'A' is output class, and dataset should be

opened for output in the program. Define a 80 byte record layout for the file.



Q57) What are the differences between OS VS COBOL and VS COBOL II?

A57) OS/VS Cobol pgms can only run in 24 bit addressing mode, VS Cobol II pgms can run either in 24 bit or 31 bit

addressing modes.



I. Report writer is supported only in OS/VS Cobol.

II. USAGE IS POINTER is supported only in VS COBOL II.

III. Reference modification e.g.: WS-VAR(1:2) is supported only in VS COBOL II.

IV. EVALUATE is supported only in VS COBOL II.

V. Scope terminators are supported only in VS COBOL II.

VI. OS/VS Cobol follows ANSI 74 stds while VS COBOL II follows ANSI 85 stds.

VII. Under CICS Calls between VS COBOL II programs are supported.



Q58) What are the steps you go through while creating a COBOL program executable?

A58) DB2 precompiler (if embedded SQL used), CICS translator (if CICS pgm), Cobol compiler, Link editor. If DB2

program, create plan by binding the DBRMs.



Q59) Can you call an OS VS COBOL pgm from a VS COBOL II pgm ?

A59) In non-CICS environment, it is possible. In CICS, this is not possible.


Q60) What are the differences between COBOL and COBOL II?

A60) There are at least five differences:

COBOL II supports structured programming by using in line Performs and explicit scope terminators, It introduces

new features (EVALUATE, SET. TO TRUE, CALL. BY CONTEXT, etc) It permits programs to be loaded and

addressed above the 16-megabyte line It does not support many old features (READY TRACE, REPORT-WRITER,

ISAM, Etc.), and It offers enhanced CICS support.



Q61) What is an explicit scope terminator?

A61) A scope terminator brackets its preceding verb, e.g. IF .. END-IF, so that all statements between the verb and its scope terminator are grouped together. Other common COBOL II verbs are READ, PERFORM, EVALUATE, SEARCH and STRING.



Q62) What is an in line PERFORM? When would you use it? Anything else to say about it?
A62) The PERFORM and END-PERFORM statements bracket all COBOL II statements between them. The COBOL equivalent is to PERFORM or PERFORM THRU a paragraph. In line PERFORMs work as long as there are no internal GO TOs, not even to an exit. The in line PERFORM for readability should not exceed a page length - often it will reference other PERFORM paragraphs.



Q63) What is the difference between NEXT SENTENCE and CONTINUE?
A63) NEXT SENTENCE gives control to the verb following the next period. CONTINUE gives control to the next verb after the explicit scope terminator. (This is not one of COBOL II's finer implementations). It's safest to use CONTINUE rather than NEXT SENTENCE in COBOL II.



Q64) What COBOL construct is the COBOL II EVALUATE meant to replace?
A64) EVALUATE can be used in place of the nested IF THEN ELSE statements.



Q65) What is the significance of 'above the line' and 'below the line'?
A65) Before IBM introduced MVS/XA architecture in the 1980's a program's virtual storage was limited to 16 megs. Programs compiled with a 24 bit mode can only address 16 Mb of space, as though they were kept under an imaginary storage line. With COBOL II a program compiled with a 31 bit mode can be 'above the 16 Mb line. (This 'below the line', 'above the line' imagery confuses most mainframe programmers, who tend to be a literal minded group.)



Q66) What was removed from COBOL in the COBOL II implementation?
A66) Partial list: REMARKS, NOMINAL KEY, PAGE-COUNTER, CURRENT-DAY, TIME-OF-DAY, STATE, FLOW, COUNT, EXAMINE, EXHIBIT, READY TRACE and RESET TRACE.



Q67) Explain call by context by comparing it to other calls.

A67) The parameters passed in a call by context are protected from modification by the called program. In a normal call they are able to be modified.



Q68) What is the linkage section?
A68) The linkage section is part of a called program that 'links' or maps to data items in the calling program's working storage. It is the part of the called program where these share items are defined.



Q69) What is the difference between a subscript and an index in a table definition?
A69) A subscript is a working storage data definition item, typically a PIC (999) where a value must be moved to the subscript and then incremented or decrements by ADD TO and SUBTRACT FROM statements. An index is a register item that exists outside the program's working storage. You SET an index to a value and SET it UP BY value and DOWN BY value.



Q70) If you were passing a table via linkage, which is preferable - a subscript or an index?
A70) Wake up - you haven't been paying attention! It's not possible to pass an index via linkage. The index is not part of the calling programs working storage. Those of us who've made this mistake, appreciate the lesson more than others.



Q71) Explain the difference between an internal and an external sort, the pros and cons, internal sort syntax etc.

A71) An external sort is not COBOL; it is performed through JCL and PGM=SORT. It is understandable without any code reference. An internal sort can use two different syntax’s: 1.) USING, GIVING sorts are comparable to external sorts with no extra file processing; 2) INPUT PROCEDURE, OUTPUT PROCEDURE sorts allow for data manipulation before and/or after the sort.



Q72) What is the difference between comp and comp-3 usage? Explain other COBOL usage’s.

A72) Comp is a binary usage, while comp-3 indicates packed decimal. The other common usage’s are binary and display. Display is the default.



Q73) When is a scope terminator mandatory?
A73) Scope terminators are mandatory for in-line PERFORMS and EVALUATE statements. For readability, it's recommended coding practice to always make scope terminators explicit.



Q74) In a COBOL II PERFORM statement, when is the conditional tested, before or after the perform execution?

A74) In COBOL II the optional clause WITH TEST BEFORE or WITH TEST AFTER can be added to all perform statements. By default the test is performed before the perform.



Q75) In an EVALUTE statement is the order of the WHEN clauses significant?
A75) Absolutely. Evaluation of the WHEN clauses proceeds from top to bottom and their sequence can determine results.



Q76) What is the default value(s) for an INITIALIZE and what keyword allows for an override of the default.

A76) INITIALIZE moves spaces to alphabetic fields and zeros to alphanumeric fields. The REPLACING option can be used to override these defaults.



Q77) What is SET TO TRUE all about, anyway?
A77) In COBOL II the 88 levels can be set rather than moving their associated values to the related data item. (Web note: This change is not one of COBOL II's better specifications.)



Q78) What is LENGTH in COBOL II?
A78) LENGTH acts like a special register to tell the length of a group or elementary item.



Q79) What is the difference between a binary search and a sequential search? What are the pertinent COBOL

commands?

A79) In a binary search the table element key values must be in ascending or descending sequence. The table is 'halved' to search for equal to, greater than or less than conditions until the element is found. In a sequential search the table is searched from top to bottom, so (ironically) the elements do not have to be in a specific sequence. The binary search is much faster for larger tables, while sequential works well with smaller ones. SEARCH ALL is used for binary searches; SEARCH for sequential.



Q80) What is the point of the REPLACING option of a copy statement?
A80) REPLACING allows for the same copy to be used more than once in the same code by changing the replace value.

Read More

Software Testing

1. Software Testing is more Oriented to Detecting the defects or often equated to finding bugs. Testing is a process of executing a software system to determine whether it matches its specification and executes in its intended environment under controlled conditiions. The controlled conditions should include both normal and abnormal conditions. Testing should intentionally attempt to make things go wrong to determine if things happen when they shouldn't or things don't happen when they should.

SQA: - Software QA involves the entire software development PROCESS - monitoring and improving the process, making sure that any agreed-upon standards and procedures are followed, and ensuring that problems are found and dealt with. It is oriented to 'prevention'.

Stop Testing: -
Testing is potentially endless. We can not test till all the defects are unearthed and removed -- it is simply impossible. At some point, we have to stop testing and ship the software. The question is when.

Realistically, testing is a trade-off between budget, time and quality. It is driven by profit models. The pessimistic, and unfortunately most often used approach is to stop testing whenever some, or any of the allocated resources -- time, budget, or test cases -- are exhausted. The optimistic stopping rule is to stop testing when either reliability meets the requirement, or the benefit from continuing testing cannot justify the testing cost. [Yang95] This will usually require the use of reliability models to evaluate and predict reliability of the software under test. Each evaluation requires repeated running of the following cycle: failure data gathering -- modeling -- prediction. This method does not fit well for ultra-dependable systems, however, because the real field failure data will take too long to accumulate.

For Verification & Validation (V&V)
Just as topic Verification and Validation indicated, another important purpose of testing is verification and validation (V&V). Testing can serve as metrics. It is heavily used as a tool in the V&V process. Testers can make claims based on interpretations of the testing results, which either the product works under certain situations, or it does not work. We can also compare the quality among different products under the same specification, based on results from the same test.

2. What is the purpose of software testing?
The purpose of software testing is
a. To demonstrate that the product performs each function intended;
b. To demonstrate that the internal operation of the product performs according to specification and all internal components have been adequately exercised;
c. To increase our confidence in the proper functioning of the software.
d. To show the product is free from defect.
e. All of the above.

3. Types of Levels: -
COMPATIBILITY TESTING. Testing to ensure compatibility of an application or Web site with different browsers, OSs, and hardware platforms. Compatibility testing can be performed manually or can be driven by an automated functional or regression test suite.

CONFORMANCE TESTING. Verifying implementation conformance to industry standards. Producing tests for the behavior of an implementation to be sure it provides the portability, interoperability, and/or compatibility a standard defines.

FUNCTIONAL TESTING. Validating an application or Web site conforms to its specifications and correctly performs all its required functions. This entails a series of tests which perform a feature by feature validation of behavior, using a wide range of normal and erroneous input data. This can involve testing of the product's user interface, APIs, database management, security, installation, networking, etcF testing can be performed on an automated or manual basis using black box or white box methodologies.

LOAD TESTING. Load testing is a generic term covering Performance Testing and Stress Testing.

PERFORMANCE TESTING. Performance testing can be applied to understand your application or WWW site's scalability, or to benchmark the performance in an environment of third party products such as servers and middleware for potential purchase. This sort of testing is particularly useful to identify performance bottlenecks in high use applications. Performance testing generally involves an automated test suite as this allows easy simulation of a variety of normal, peak, and exceptional load conditions.

REGRESSION TESTING. Similar in scope to a functional test, a regression test allows a consistent, repeatable validation of each new release of a product or Web site. Such testing ensures reported product defects have been corrected for each new release and that no new quality problems were introduced in the maintenance process. Though regression testing can be performed manually an automated test suite is often used to reduce the time and resources needed to perform the required testing.

SMOKE TESTING. A quick-and-dirty test that the major functions of a piece of software work without bothering with finer details. Originated in the hardware testing practice of turning on a new piece of hardware for the first time and considering it a success if it does not catch on fire.

STRESS TESTING. Testing conducted to evaluate a system or component at or beyond the limits of its specified requirements to determine the load under which it fails and how. A graceful degradation under load leading to non-catastrophic failure is the desired result. Often Stress Testing is performed using the same process as Performance Testing but employing a very high level of simulated load.

UNIT TESTING. Functional and reliability testing in an Engineering environment. Producing tests for the behavior of components of a product to ensure their correct behavior prior to system integration.

Black Box Testing
Black box testing methods focus on the functional requirements of the software. Tests sets are derived that fully exercise all functional requirements. This strategy tends to be applied during the latter part of the lifecycle.
Tests are designed to answer questions such as:

1) How is functional validity tested?
2) What classes of input make good test cases?
3) Is the system particularly sensitive to certain input values?
4) How are the boundaries of data classes isolated?
5) What data rates or volumes can the system tolerate?
6) What effect will specific combinations of data have on system operation?

Equivalence Partitioning: -
This method divides the input of a program into classes of data. Test case design is based on defining an equivalent class for a particular input. An equivalence class represents a set of valid and invalid input values.
Guidelines for equivalence partitioning -

1) If an input condition specifies a range, one valid and two invalid equivalence classes are defined.
2) If an input condition requires a specific value, one valid and two invalid equivalence classes are defined.
3) If an input condition specifies a member of a set, one valid and one invalid equivalence class are defined.
4) If an input condition is boolean, one valid and one invalid class are defined.

Boundary Value Analysis: -
Boundary value analysis is complementary to equivalence partitioning. Rather than selecting arbitrary input values to partition the equivalence class, the test case designer chooses values at the extremes of the class. Furthermore, boundary value analysis also encourages test case designers to look at output conditions and design test cases for the extreme conditions in output.
Guidelines for boundary value analysis -

1) If an input condition specifies a range bounded by values a and b, test cases should be designed with values a and b, and values just above and just below and b.
2) If an input condition specifies a number of values, test cases should be developed that exercise the minimum and maximum numbers. Values above and below the minimum and maximum are also tested.
3) Apply the above guidelines to output conditions. For example, if the requirement specifies the production of an table as output then you want to choose input conditions that produce the largest and smallest possible table.
4) For internal data structures be certain to design test cases to exercise the data structure at its boundary. For example, if the software includes the maintenance of a personnel list, then you should ensure the software is tested with conditions where the list size is 0, 1 and maximum (if constrained).

Cause-Effect Graphs
A weakness of the two methods is that do not consider potential combinations of input/output conditions. Cause-effect graphs connect input classes (causes) to output classes (effects) yielding a directed graph.
Guidelines for cause-effect graphs -

1) Causes and effects are listed for a modules and an identifier is assigned to each.
2) A cause-effect graph is developed (special symbols are required).
3) The graph is converted to a decision table.
4) Decision table rules are converted to test cases.

We can not test quality directly, but we can test related factors to make quality visible. Quality has three sets of factors -- functionality, engineering, and adaptability. These three sets of factors can be thought of as dimensions in the software quality space. Each dimension may be broken down into its component factors and considerations at successively lower levels of detail.

Performance testing
Not all software systems have specifications on performance explicitly. But every system will have implicit performance requirements. The software should not take infinite time or infinite resource to execute. "Performance bugs" sometimes are used to refer to those design problems in software that cause the system performance to degrade.

Reliability testing
Software reliability refers to the probability of failure-free operation of a system. It is related to many aspects of software, including the testing process. Directly estimating software reliability by quantifying its related factors can be difficult. Testing is an effective sampling method to measure software reliability. Guided by the operational profile, software testing (usually black-box testing) can be used to obtain failure data, and an estimation model can be further used to analyze the data to estimate the present reliability and predict future reliability. Therefore, based on the estimation, the developers can decide whether to release the software, and the users can decide whether to adopt and use the software. Risk of using software can also be assessed based on reliability information. [Hamlet94] advocates that the primary goal of testing should be to measure the dependability of tested software.

Security testing
Software quality, reliability and security are tightly coupled. Flaws in software can be exploited by intruders to open security holes. With the development of the Internet, software security problems are becoming even more severe.
Many critical software applications and services have integrated security measures against malicious attacks. The purpose of security testing of these systems include identifying and removing software flaws that may potentially lead to security violations, and validating the effectiveness of security measures. Simulated security attacks can be performed to find vulnerabilities.

TESTING means "quality control"
* QUALITY CONTROL measures the quality of a product
* QUALITY ASSURANCE measures the quality of processes used to create a quality product.
Beta testing is typically conducted by end users of a software product who are not paid a salary for their efforts.

Acceptance Testing
Testing the system with the intent of confirming readiness of the product and customer acceptance.

Ad Hoc Testing
Testing without a formal test plan or outside of a test plan. With some projects this type of testing is carried out as an adjunct to formal testing. If carried out by a skilled tester, it can often find problems that are not caught in regular testing. Sometimes, if testing occurs very late in the development cycle, this will be the only kind of testing that can be performed. Sometimes ad hoc testing is referred to as exploratory testing.

Alpha Testing
Testing after code is mostly complete or contains most of the functionality and prior to users being involved. Sometimes a select group of users are involved. More often this testing will be performed in-house or by an outside testing firm in close cooperation with the software engineering department.

Automated Testing
Software testing that utilizes a variety of tools to automate the testing process and when the importance of having a person manually testing is diminished. Automated testing still requires a skilled quality assurance professional with knowledge of the automation tool and the software being tested to set up the tests.

Beta Testing
Testing after the product is code complete. Betas are often widely distributed or even distributed to the public at large in hopes that they will buy the final product when it is released.

Black Box Testing
Testing software without any knowledge of the inner workings, structure or language of the module being tested. Black box tests, as most other kinds of tests, must be written from a definitive source document, such as a specification or requirements document..

Compatibility Testing
Testing used to determine whether other system software components such as browsers, utilities, and competing software will conflict with the software being tested.

Configuration Testing
Testing to determine how well the product works with a broad range of hardware/peripheral equipment configurations as well as on different operating systems and software.

Functional Testing
Testing two or more modules together with the intent of finding defects, demonstrating that defects are not present, verifying that the module performs its intended functions as stated in the specification and establishing confidence that a program does what it is supposed to do.

Independent Verification and Validation (IV&V)
The process of exercising software with the intent of ensuring that the software system meets its requirements and user expectations and doesn't fail in an unacceptable manner. The individual or group doing this work is not part of the group or organization that developed the software. A term often applied to government work or where the government regulates the products, as in medical devices.

Installation Testing
Testing with the intent of determining if the product will install on a variety of platforms and how easily it installs.

Integration Testing
Testing two or more modules or functions together with the intent of finding interface defects between the modules or functions. Testing completed at as a part of unit or functional testing, and sometimes, becomes its own standalone test phase. On a larger level, integration testing can involve a putting together of groups of modules and functions with the goal of completing and verifying that the system meets the system requirements. (see system testing)

Load Testing
Testing with the intent of determining how well the product handles competition for system resources. The competition may come in the form of network traffic, CPU utilization or memory allocation.

Performance Testing
Testing with the intent of determining how quickly a product handles a variety of events. Automated test tools geared specifically to test and fine-tune performance are used most often for this type of testing.

Pilot Testing
Testing that involves the users just before actual release to ensure that users become familiar with the release contents and ultimately accept it. Often is considered a Move-to-Production activity for ERP releases or a beta test for commercial products. Typically involves many users, is conducted over a short period of time and is tightly controlled. (see beta testing)

Regression Testing
Testing with the intent of determining if bug fixes have been successful and have not created any new problems. Also, this type of testing is done to ensure that no degradation of baseline functionality has occurred.

Security Testing
Testing of database and network software in order to keep company data and resources secure from mistaken/accidental users, hackers, and other malevolent attackers.

Software Testing
The process of exercising software with the intent of ensuring that the software system meets its requirements and user expectations and doesn't fail in an unacceptable manner. The organization and management of individuals or groups doing this work is not relevant. This term is often applied to commercial products such as internet applications. (contrast with independent verification and validation)

Stress Testing
Testing with the intent of determining how well a product performs when a load is placed on the system resources that nears and then exceeds capacity.

System Integration Testing
Testing a specific hardware/software installation. This is typically performed on a COTS (commerical off the shelf) system or any other system comprised of disparent parts where custom configurations and/or unique installations are the norm.

White Box Testing
Testing in which the software tester has knowledge of the inner workings, structure and language of the software, or at least its purpose.

Difference Between Verification & Validation: -
- Verification is about answering the question "Does the system function properly?" or "Have we built the system right?"
- Validation is about answering the question "Is the product what the customer wanted?" or "Have we built the right system?"

This definition indicates that Validation could be the same thing as Acceptance Test (or at least very similar).

I have often described Verification and Validation processes in the same way, ie:

1. Plan the test (output Test Plan)
2. Specify the test (output Test Specification)
3. Perform the test (output Test Log and/or Test Report

Verification & Validation
Verification typically involves reviews and meetings to evaluate documents, plans, code, requirements, and specifications. This can be done with checklists, issues lists, walkthroughs, and inspection meetings. Validation typically involves actual testing and takes place after verifications are completed. The term 'IV & V' refers to Independent Verification and Validation.

Read More

Common Interview Ques and Ans.

1.Tell me about yourself.
The most often asked question in interviews. You need to have a short statement prepared in your mind. Be careful that it does not sound rehearsed. Limit it to work-related items unless instructed otherwise. Talk about things you have done and jobs you have held that relate to the position you are interviewing for. Start with the item farthest back and work up to the present.

2.Do you consider yourself successful?
You should always answer yes and briefly explain why. A good explanation is that you have set goals, and you have met some and are on tract to achieve the others.

3.Why did you leave your last job?
Stay positive regardless of the circumstances. Never refer to a major problem with management and never speak ill of supervisors, co-workers, or the organization. If you do, you will be the one looking bad. Keep smiling and talk about leaving for a positive reason such as an opportunity, a chance to do something special, or other forward-looking reasons.



4.What experience do you have in this field?
Speak about specifics that relate to the position you are applying for. If you do not have specific experience, get as close as you can.

5.What do you know about this organization?
This question is one reason to do some research on the organization before the interview. Find out where they have been, and where they are going. What are the current issues, and who are the major players?

6.What have you done to improve your knowledge in the last year?
Try to include improvement activities that relate to the job. A wide variety of activities can be mentioned as positive self-improvement. Have some good ones handy to mention.

7.Are you applying for other jobs?
Be honest but do not spend a lot of time in this area. Keep the focus on this job and what you can do for this organization. Anything else is a distraction.

8.What do co-workers say about you?
Be prepared with a quote or two from co-workers. Either a specific statement or a paraphrase will work. "Jill Clark, a co-worker at Smith Company, always said I was the hardest worker she had ever known." It is as powerful as Jill having said it at the interview herself.

9.Why do you want to work for this organization?
This may take some thought and certainly should be based on the research you have done on the organization, Sincerity is extremely important here, and will easily be sensed. Relate it to your long-term career goals.

10.Do you know anyone who works for us?
Be aware of the policy on relatives working for the organization. This can affect your answer even though they asked about friends not relatives. Be careful to mention a friend only if they are will thought of.

11.What kind of salary do you need?
A loaded question. A nasty little game that you will probably lose if you answer first. So, do not answer it. Instead, say something like, "That's a tough question. Can you tell me the range for this position?" In most cases, the interviewer, taken off guard, will tell you. If not, say that it can depend on the details of the job. Then give a wide range.

12.Are you a team player?
You are, of course, a team player, Be sure to have examples ready. Specifics that show you often perform for the good of the team rather than for yourself are good evidence of your team attitude. Do not brag, just say it in a matter-of-fact tone. This is a key point.

13.How long would you expect to work for us if hired?
Specifics here are not good. Something like this should work: "I'd like it to be a long time." Or "As long as we both feel I'm doing a good job."

14.Have you ever had to fire anyone? How did you feel about that?
This is serious. Do not make light of it or in any way seem like you like to fire people. At the same time, you will do it when it is the right thing to do. When it comes to the organization versus the individual who has created a harmful situation, you will protect the organization. Remember firing is not the same as layoff or reduction in force.

15.What is your philosophy towards work?
The interviewer is not looking for a long or flowery dissertation here. Do you have strong feelings that the job gets done? Yes. That's the type of answer that works best here. Short and positive, showing a benefit to the organization.

16.If you had enough money to retire right now, would you?
Answer yes if you would, But since you need to work, this is the type of work you prefer. Do not say yes if you do not mean it.

17.Have you ever been asked to leave a position?
If you have not, say no. If you have, be honest, brief, and avoid saying negative things about the people or organization involved.

18.Explain how you would be an asset to this organization.
You should be anxious for this question. It gives you a chance to highlight your best points as they relate to the position being discussed. Give a little advance thought to this relationship.

19.Why should we hire your?
Point out how your assets meet what the organization needs. Do not mention any other candidates to make a comparison.

Tell me about a suggestion you have made.
Have a good one ready. Be sure and use a suggestion that was accepted and was then considered successful. One related to the type of work applied for is a real plus.

What irritates you about co-workers?
This a trap question. Think "real hard" but fail to come up with anything that irritates you. A short statement that you seem to get along with folks is great.

20.What are your greatest weaknesses?
Assure the interviewer that you can think of nothing that would stand in the way of your performing in this position with excellence. Then, quickly review you strongest qualifications.
Example: "Nobody's perfect, but based on what you've told me about this position, I believe I' d make an outstanding match. I know that when I hire people, I look for two things most of all. Do they have the qualifications to do the job well, and the motivation to do it well? Everything in my background shows I have both the qualifications and a strong desire to achieve excellence in whatever I take on. So I can say in all honesty that I see nothing that would cause you even a small concern about my ability or my strong desire to perform this job with excellence."

Alternate strategy (if you don't yet know enough about the position to talk about such a perfect fit): Instead of confessing a weakness, describe what you like most and like least, making sure that what you like most matches up with the most important qualification for success in the position, and what you like least is not essential.

Example: Let's say you're applying for a teaching position. "If given a choice, I like to spend as much time as possible in front of my prospects selling, as opposed to shuffling paperwork back at the office. Of course, I long ago learned the importance of filing paperwork properly, and I do it conscientiously. But what I really love to do is sell (if your interviewer were a sales manager, this should be music to his ears.)

21What is your greatest strength?
Numerous answers are good, just stay positive. A few good examples: your ability to prioritize.
You know that your key strategy is to first uncover your interviewer's greatest wants and needs before you answer questions.

Prior to any interview, you should have a list mentally prepared of your greatest strengths. You should also have, a specific example or two, which illustrates each strength, an example chosen from your most recent and most impressive achievements.

As a general guideline, the 10 most desirable traits that all employers love to see in their employees are:
• Your problem-solving skills.
• Your ability to work under pressure.
• Your ability to focus on projects.
• Your professional expertise.
• Your leadership skills.
• Your positive attitude.
• Tell me about your dream job.
• Definiteness of purpose...clear goals.
• Enthusiasm...high level of motivation.
• Likeability...positive attitude...sense of humor.

Stay away from a specific job. You cannot win. If you say the job you are contending for is it, you strain credibility. If you say another job is it, you plant the suspicion that you will be dissatisfied with this position if hired. The best bet is to stay generic and say something like: "A job where I love the work, like the people, can contribute, and can't wait to get to work."

22.Why do you think you would do well at this job?
Give several reasons and include skills, experience, and interest.

23.What are you looking for in a job?
Stay away from a specific job. You cannot win. If you say the job you are contending for is it, you strain credibility. If you say another job is it, you plant the suspicion that you will be dissatisfied with this position if hired. The best bet is to stay generic and say something like: "A job where I love the work, like the people, can contribute, and can't wait to get to work."

24.What kind of person would you refuse to work with?
Do not be trivial, It would take disloyalty to the organization, violence or lawbreaking to get you to object. Minor objections will label you as a whiner.

25.What is more important to you: the money or the work?
Money is always important, but the work is the most important. There is not better answer.

26.What would your previous supervisor say your strongest point is?
• Loyalty
• Energy
• Positive attitude
• Leadership
• Team Player
• Expertise
• Initiative
• Patience
• Hard Work
• Creativity
• Problem solver
• Tell me about a problem you had with a supervisor.
Biggest trap of all. This is a test to see if you will speak ill of your boss. If you fall for it and tell about a problem with a former boss, you may well blow the interview right there. Stay positive and develop a poor memory about any trouble with a superior.

27.What has disappointed you about a job?
Don't get trivial or negative. Safe areas are few but can include.
• Not enough of a challenge.
• You were laid off in a reduction.
• Company did not win a contract, which would have given you more responsibility.

28.Tell me about your ability to work under pressure.
You may say that you thrive under certain types of pressure. Give an example that relates to the type of position applied for.

29.Do your skills match this job or another job more closely?
Probably this one. Do not give fuel to the suspicion that you may want another job more than this one.

30.What motivates you to do your best on the job?
This is a personal trait that only you can say, but good examples are:
• Challenge
• Achievement
• Recognition

31.How would you know you were successful on this job?
Several ways are good measures:
Ø You Set high standards for yourself and meet them.
Ø Your outcomes are a success.
Ø Your boss tells you that you are successful.

32.Would you be willing to relocate if required?
You should be clear on this with your family prior to the interview if you think there is a chance it may come up. Do not say yes just to get the job if the real answer is no. This can create a lot of problems later on in your career. Be honest at this point and save yourself future grief.

33.Describe your management style.
Try to avoid labels. Some of the more common labels, like "progressive", "Salesman" or "Consensus", can have several meanings or descriptions depending on which management expert you listen to. The "situational" style is safe, because it says you will manage according to the situation, instead of "one size fits all."

34.Do you have any blind spots?
Trick question, if you know about blind spots, they are no longer blind spots. Do not reveal any personal areas of concern here. Let them do their own discovery on your bad points. Do not hand it to them.

35.How do you propose to compensate for your lack of experience?
First, if you have experience that the interviewer does not know about, bring that up. Then, point out (if true) that you are a hard working quick learner.

36.What qualities do you look for in a boss?
Be generic and positive, safe qualities are knowledgeable, a sense of humor, fair, loyal to subordinates, and holder of high standards. All bosses think they have these traits.

37.Describe a bad decision you made.
The major pitfall that interviewee's often exhibit with this question is that they make the "bad decision"something they did when they were ten years old. The idea here is not to avoid the question. Pick something from the relevant past. We all make mistakes and a hallmark of honesty is admitting that and a hallmark of self-awareness is being able to recognize when we made those mistakes.
Do not put your mistake so far back in the past that you are obviously picking something that is "harmless" but if you feel the need to do this, you might say something like, "Well, I have more current answers but I have one from my past that really stuck with me." If you go that route, then explain why that decision "stuck with you" and, more importantly, how it is has guided your actions in other areas so as to not make that kind of bad decision again. The real point here, for the candidate, is to turn this into a "lesson learned" answer. State your bad decision, make it clear why you perceive this was a bad decision, and then talk about what you learned from that.

38.Describe your work ethic.
Emphasize benefits to the organization. Things like, "determination to get the job done" and "work hard but enjoy your work" are good.

39.Do you have any questions for me?
Always have some questions prepared. Questions involving areas where you will be an asset to the organization are good. "How soon will I be able to be productive?" and "What type of projects will I be able to assist on?" are examples.

Read More

General Aptitude

1. A man starts his walking at 3PM from point A, he walks at the rate of 4km/hr in plains and 3km/hr in hills to reach the point B. During his return journey he walks at the rate of 6km/hr in hills and 4km/hr in plains and reaches the point A at 9PM.What is the distance between A and B?

Ans: 12km

Solution:

T1+T2=6
T1-time for forward journey,
T2-time for return journey
D1+D2=forward /return distance
D1-distance in plains
D2-distance in hills
D1/4 +D2/3=T1 (forward time)
D1/4 +D2/6=T2 (return time)
Adding we will get D1+D2=12 km
2. A boy asks his father, " what is the age of grand father?". Father replied " He is x years old in x^2 years", and also said, "we are talking about 20th century". what is the year of birth of grand father?

Ans: 1892

3. A boy travels in a scooter after covering 2/3rd of the distance the wheel got punctured he covered the remaining distance by walk. Walking time is twice that of the time the boy’s riding time. How many times the riding speed as that of the walking speed?

Ans: 4 times.

4. In a Knockout tournament 51 teams are participated, every team thrown out of the tournament if they lost twice. How many matches to be held to choose the winner?

Ans: 101 matches

5. A man sold 2 pens. Initial cost of each pen was Rs. 12. If he sell it together one at 25% profit and another 20% loss. Find the amount of loss or gain, if he sells them separately.

Ans: 60 Paise gain

6. Find the 3 digit no. whose last digit is the square root of the first digit and second digit is the sum of the other two digits.

Ans: 462

7. Meera was playing with her brother using 55 blocks. She gets bored playing and starts arranging the blocks such that the no. of blocks in each row is one less than that in the lower row. Find how many were there in the bottom most row?

Ans: 10

8. Two people are playing with a pair of dies. Instead of numbers, the dies have different colors on their sides. The first person wins if the same color appears on both the dies and the second person wins if the colors are different. The odds of their winning are equal. If the first dice has 5 red sides and 1 blue side, find the color(s) on the second one.

Ans: 3 Red, 3 Blue

9. A person travels in a car with uniform speed. He observes the milestone, which has 2 digits. After one hour he observes another milestone with same digits reversed. After another hour he observes another milestone with same 2 digits separated by 0. Find the speed of the car?

Ans : 45

10. Three persons A, B &C went for a robbery in different directions and they theft one horse, one mule and one camel. They were caught by the police and when interrogated gave the following statements
A: B has stolen the horse

B: I didn't rob anything.

C: both A & B are false and B has stolen the mule.

The person who has stolen the horse always tell the truth and

The person who has stolen the camel always tell the lie.

Find who has stolen which animal?

Ans:

A- camel

B- mule

C- horse

11. One quarter of the time till now from midnight and half of the time remaining from now up to midnight adds to the present time. What is the present time?

Ans: 9:36AM

12. After world war II three departments did as follows First department gave some tanks to 2nd &3rd departments equal to the number they are having. Then 2nd department gave some tanks to 1st & 3rd departments equal to the number they are having. Then 3rd department gave some tanks to 2nd &1st departments equal to the number they are having. Then each department has 24 tanks. Find the initial number of tanks of each department?

Ans :

A-39

B-21

C-12

13. A, B, C, D&E are having their birthdays on consecutive days of the week not necessarily in the same order. A 's birthday comes before G's as many days as B's birthday comes after E's. D is older than E by 2 days. This time G's birthday came on Wednesday. Then find the day of each of their birthdays?

Ans:
Birthday of D on SUNDAY
Birthday of B on MONDAY
Birthday of E on TUESDAY
Birthday of G on WEDNESDAY
Birthday of A on THURSDAY
14. A girl 'A' told to her friend about the size and color of a snake she has seen in the beach. It is one of the colors brown/black/green and one of the sizes 35/45/55.

If it were not green or if it were not of length 35 it is 55.
If it were not black or if it were not of length 45 it is 55.
If it were not black or if it were not of length 35 it is 55.
a) What is the color of the snake?
b) What is the length of the snake?
Ans:

a) brown

b) 55

15. There are 2 persons each having same amount of marbles in the beginning. after that 1 person gain 20 more from second person n he eventually lose two third of it during the play n the second person now have 4 times marble of what 1st person is having now. find out how much marble did each had in the beginning.

Ans - 100 each

16. A lady was out for shopping. she spent half of her money in buying A and gave 1 dollar to bagger. father she spent half of her remaining money and gave 2 dollar to charity. further she spent half of remaining money n gave 3 dollar to some children. now she has left with 1 dollar. how much she had in the beginning?

Ans: $42

17. There are certain diamonds in a shop.

1 thief stole half of diamonds and 2 more.

2 thief stole half of remaining and 2 more

3. same as above

4 same as above.

5 came nothing was left for that.

how many diamonds was there???

Ans: 60 diamonds

18. There are three friends A B C.

1. Either A or B is oldest

2. Either C is oldest or A is youngest.

Who is Youngest and who is Oldest?

Ans: A is youngest n B is oldest.

19. Father says my son is five times older than my daughter. my wife is 5 times older that my son. I am twice old from my wife and altogether (sum of our ages) is equal to my mother 's age and she is celebrating her 81 birthday. so what is my son's age?

Ans: 5 years.

20. Fodder, Wheat and Rice often eat dinner out.



a) each orders either coffee or tea after dinner.

b) if fodder orders coffee, then Wheat orders the drink that Rice orders

c) if Wheat orders coffee, then fodder orders the drink that Rice does not order

d) if Rice orders tea, then fodder orders the drink that Wheat orders



which person/persons always orders the same drink after dinner ?



Ans: Fodder

21. We are given 100 pieces of a puzzle. If fixing two components together is counted as 1 move ( a component can be one piece or an already fixed set of pieces), how many moves do we need to fix the entire puzzle.

Ans: 99

22. Two guys work at some speed...After some time one guy realizes he has done only half of the other guy completed which is equal to half of what is left !

So how much faster than the other is this guy supposed to do to finish with the first...

Ans: one and half times or 3/2

23. There is a square cabbage patch. He told his sister that i have a larger patch than last year and hence 211 more cabbages this year. Then how many cabbages I have this year.?

Ans:106*106=11236

24. There are three guesses on the color of a mule

1 says: its not black

2 says: its brown or grey

3 says: its brown

At least one of them is wrong and one of them is true.....Then what’s the color of mule?

Ans: Grey

25. There are two containers on a table. A and B . A is half full of wine, while B, which is twice A's size, is one quarter full of wine . Both containers are filled with water and the contents are poured into a third container C. What portion of container C's mixture is wine ?

Ans:33.33%

26. A man was on his way to a marriage in a car with a constant speed. After 2 hours one of the tier is punctured and it took 10 minutes to replace it. After that they traveled with a speed of 30 miles/hr and reached the marriage 30 minutes late to the scheduled time. The driver told that they would be late by 15 minutes only if the 10 minutes was not waste. Find the distance between the two towns?

Ans: 120 miles

27. Farmer Jones sold a pair of cows for Rs. 210 , On one he made a profit of ten percent and on the other he lost ten percent. Although he made a profit of five percent. How many did each cow originally cost him?

Ans:150,50

28. I spent one-sixth of my age as a boy and one-12th in youth, remarked the boss "spent one-seventh and five years in matrimony". My son born just after that period was elected as a governor 4 years back when he was half of my present age. What is the age of the boss?

Ans: 84

29. A girl had several dollars with her. she went out for shopping and spent half of them in shopping mall, being generous she had given 1 dollar to the beggar. After that she went for lunch and spent the half of the remaining and gave 2 dollars as tip to the waiter. Then she went to watch a movie and spent the half of remaining dollars and gave autorikshaw-wala 3 dollars. This left her with only 1 dollar. How many dollars did she had with her at the beginning.

Ans:$42.

30. A bargain hunter bought some plates for $ 1.30 from a sale on Saturday, where price 2cents was marked off at each article .On Monday she went to return them at regular prices, and bought some cups and saucers from that much amount of money only. The normal price of plate were equal to the price of 'one cup and one saucer'. In total she bought 16 items more than previous. saucers were only of 3 cents hence she brought 10 saucers more than the cups, How many cups and saucers she bought and at what price?

Ans: 8,18 Price: 12,3.

31. Mr. T has a wrong weighing pan. One arm is lengthier than other.1 kilogram on left balances 8 melons on right.1 kilogram on right balances 2 melons on left. If all melons are equal in weight, what is the weight of a single melon?

Ans:200 gms

32. A card board of 34 * 14 has to be attached to a wooden box and a total of 35 pins are to be used on the each side of the cardbox. Find the total number of pins used .

Ans: 210

33. Last Year my cousin came to my place and we played a game where the loosing one has to give one chocolate to the person who won the game .At the end of the vacation, i.e. the day my cousin was leaving she counted number of games that i won an she won. At last she gave me a total of 8 chocolates even though she won about 12 games. Find the number of games that we played.

Ans: 20

34. Here is a five digit number. The fifth digit is one fourth of the third digit and one half of the fourth digit. Third digit is one half of the first digit. second digit is 5 more than the fifth digit.

What is that 5 digit no.?

Ans: 86421

35. A boy goes to school from his house. On one fourth of his way to school, he crosses a

machinery station. And on one third of his way to school, he crosses a Railway station.

He crossed the machinery station at 7:30 and he crosses the Railway station at 7:35.

when does he leave the house & when does he reach the school ? (5M)

Ans: 7:15 - 8:15

36. Four persons A,B,C,D were there. All were of different weights. All Four gave a

statement. Among the four statements only the person who is lightest in weight of all

others gave a true statement.

A Says : B is heavier than D.

B Says : A is heavier than C.

C Says : I am heavier than D.

D Says : C is heavier than B.

Ans: ACDB.

37. A man was traveling to a place 30 miles away from starting point. he was speeding at 60 miles/hr. but when he came back, his car got breakdown and half an hour was wasted in repairing that. altogether he took 1 hr for return journey. Find the avg. speed of the whole journey.

Ans:60 miles/hour.

Read More

OOPS Interview Questions and Answers

1. What is the difference between procedural and object-oriented programs

a) In procedural program, programming logic follows certain procedures and the instructions are executed one after another. In OOP program, unit of program is object, which is nothing but combination of data and code. b) In procedural program, data is exposed to the whole program whereas in OOPs program, it is accessible with in the object and which in turn assures the security of the code.
2. What are Encapsulation, Inheritance and Polymorphism

Encapsulation is the mechanism that binds together code and data it manipulates and keeps both safe from outside interference and misuse. Inheritance is the process by which one object acquires the properties of another object. Polymorphism is the feature that allows one interface to be used for general class actions.
3. What is the difference between Assignment and Initialization

Assignment can be done as many times as desired whereas initialization can be done only once.
4. What is OOPs

Object oriented programming organizes a program around its data, i. e. , objects and a set of well defined interfaces to that data. An object-oriented program can be characterized as data controlling access to code.
5. What are Class, Constructor and Primitive data types

Class is a template for multiple objects with similar features and it is a blue print for objects. It defines a type of object according to the data the object can hold and the operations the object can perform. Constructor is a special kind of method that determines how an object is initialized when created. Primitive data types are 8 types and they are: byte, short, int, long, float, double, boolean, char.
6. What is an Object and how do you allocate memory to it

Object is an instance of a class and it is a software unit that combines a structured set of data with a set of operations for inspecting and manipulating that data. When an object is created using new operator, memory is allocated to it.
7. What is the difference between constructor and method

Constructor will be automatically invoked when an object is created whereas method has to be called explicitly.
8. What are methods and how are they defined

Methods are functions that operate on instances of classes in which they are defined. Objects can communicate with each other using methods and can call methods in other classes. Method definition has four parts. They are name of the method, type of object or primitive type the method returns, a list of parameters and the body of the method. A method’s signature is a combination of the first three parts mentioned above.
9. How many ways can an argument be passed to a subroutine and explain them

An argument can be passed in two ways. They are passing by value and passing by reference. Passing by value: This method copies the value of an argument into the formal parameter of the subroutine. Passing by reference: In this method, a reference to an argument (not the value of the argument) is passed to the parameter.
10. What is the difference between an argument and a parameter

While defining method, variables passed in the method are called parameters. While using those methods, values passed to those variables are called arguments.
11. What are different types of access modifiers

public: Any thing declared as public can be accessed from anywhere. private: Any thing declared as private can’t be seen outside of its class. protected: Any thing declared as protected can be accessed by classes in the same package and subclasses in the other packages. default modifier : Can be accessed only to classes in the same package.
12. What are Transient and Volatile Modifiers

Transient: The transient modifier applies to variables only and it is not stored as part of its object’s Persistent state. Transient variables are not serialized. Volatile: Volatile modifier applies to variables only and it tells the compiler that the variable modified by volatile can be changed unexpectedly by other parts of the program.
13. What is method overloading and method overriding

Method overloading: When a method in a class having the same method name with different arguments is said to be method overloading. Method overriding : When a method in a class having the same method name with same arguments is said to be method overriding.
14. What is difference between overloading and overriding

a) In overloading, there is a relationship between methods available in the same class whereas in overriding, there is relationship between a superclass method and subclass method. b) Overloading does not block inheritance from the superclass whereas overriding blocks inheritance from the superclass. c) In overloading, separate methods share the same name whereas in overriding, subclass method replaces the superclass. d) Overloading must have different method signatures whereas overriding must have same signature.
15. What is meant by Inheritance and what are its advantages

Inheritance is the process of inheriting all the features from a class. The advantages of inheritance are reusability of code and accessibility of variables and methods of the super class by subclasses.
16. What is the difference between this() and super()

this() can be used to invoke a constructor of the same class whereas super() can be used to invoke a super class constructor.
17. What is the difference between superclass and subclass

A super class is a class that is inherited whereas sub class is a class that does the inheriting.
18. What modifiers may be used with top-level class

public, abstract and final can be used for top-level class.
19. What are inner class and anonymous class

Inner class : classes defined in other classes, including those defined in methods are called inner classes. An inner class can have any accessibility including private. Anonymous class : Anonymous class is a class defined inside a method without a name and is instantiated and declared in the same place and cannot have explicit constructors.
20. What is interface and its use

Interface is similar to a class which may contain method’s signature only but not bodies and it is a formal set of method and constant declarations that must be defined by the class that implements it. Interfaces are useful for: a)Declaring methods that one or more classes are expected to implement b)Capturing similarities between unrelated classes without forcing a class relationship. c)Determining an object’s programming interface without revealing the actual body of the class.
21. What is an abstract class

An abstract class is a class designed with implementation gaps for subclasses to fill in and is deliberately incomplete.
22. What is the difference between abstract class and interface

a) All the methods declared inside an interface are abstract whereas abstract class must have at least one abstract method and others may be concrete or abstract. b) In abstract class, key word abstract must be used for the methods whereas interface we need not use that keyword for the methods. c) Abstract class must have subclasses whereas interface can’t have subclasses.
23. Can you have an inner class inside a method and what variables can you access

Yes, we can have an inner class inside a method and final variables can be accessed.
24. What is the difference between Array and vector

Array is a set of related data type and static whereas vector is a growable array of objects and dynamic.
25. What is the difference between exception and error

The exception class defines mild error conditions that your program encounters. Exceptions can occur when trying to open the file, which does not exist, the network connection is disrupted, operands being manipulated are out of prescribed ranges, the class file you are interested in loading is missing. The error class defines serious error conditions that you should not attempt to recover from. In most cases it is advisable to let the program terminate when such an error is encountered.
26. What is the difference between process and thread

Process is a program in execution whereas thread is a separate path of execution in a program.
27. What is multithreading and what are the methods for inter-thread communication and what is the class in which these methods are defined

Multithreading is the mechanism in which more than one thread run independent of each other within the process. wait (), notify () and notifyAll() methods can be used for inter-thread communication and these methods are in Object class. wait() : When a thread executes a call to wait() method, it surrenders the object lock and enters into a waiting state. notify() or notifyAll() : To remove a thread from the waiting state, some other thread must make a call to notify() or notifyAll() method on the same object.

Read More

PHP - INTERVIEW QUESTIONS

1. What are the differences between GET and POST methods in form submitting, give the case where we can use get and we can use post methods?
On the server side, the main difference between GET and POST is where the submitted is stored. The $_GET array stores data submitted by the GET method. The $_POST array stores data submitted by the POST method.

On the browser side, the difference is that data submitted by the GET method will be displayed in the browser’s address field. Data submitted by the POST method will not be displayed anywhere on the browser.

GET method is mostly used for submitting a small amount and less sensitive data. POST method is mostly used for submitting a large amount or sensitive data.

2. Who is the father of php and explain the changes in php versions?
Rasmus Lerdorf for version changes go to http://php.net/ Marco Tabini is the founder and publisher of php|architect.

3. How can we submit from without a submit button?
We can use a simple JavaScript code linked to an event trigger of any form field. In the JavaScript code, we can call the document.form.submit() function to submit the form. For example:

4. How many ways we can retrieve the date in result set of mysql Using php?
As individual objects so single record or as a set or arrays.

5. What is the difference between mysql_fetch_object and mysql_fetch_array?
MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array.

6. What is the difference between $message and $$message?
They are both variables. But $message is a variable with a fixed name. $$message is a variable who’s name is stored in $message. For example, if $message contains "var", $$message is the same as $var.

7. How can we extract string ‘abc.com ‘ from a string ‘http://info@a…’ using regular _expression of php?
We can use the preg_match() function with "/.*@(.*)$/" as the regular expression pattern. For example: preg_match("/.*@(.*)$/","http://info@abc.com",$data); echo $data[1];

8. How can we create a database using php and mysql?
PHP: mysql_create_db()
Mysql: create database;

9. What are the differences between require and include, include_once?
File will not be included more than once. If we want to include a file once only and further calling of the file will be ignored then we have to use the PHP function include_once(). This will prevent problems with function redefinitions, variable value reassignments, etc.

10. Can we use include ("abc.php") two times in a php page "makeit.php"?
Yes we can include..

11. What are the different tables present in mysql, which type of table is generated when we are creating a table in the following
syntax: create table employee(eno int(2),ename varchar(10)) ?

Total 5 types of tables we can create
1. MyISAM
2. Heap
3. Merge
4. InnoDB
5. ISAM
6. BDB
MyISAM is the default storage engine as of MySQL 3.23.

12. Functions in IMAP, POP3 AND LDAP?
Please visit:
http://fi2.php.net/imap
http://uk2.php.net/ldap

13. How can I execute a php script using command line?
Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the command line argument. For example, "php myScript.php", assuming "php" is the command to invoke the CLI program.
Be aware that if your PHP script was written for the Web CGI interface, it may not execute properly in command line environment.

14. Suppose your ZEND engine supports the mode Then how can u configure your php ZEND engine to support mode ?
If you change the line: short_open_tag = off in php.ini file. Then your php ZEND engine support only mode.

15. Shopping cart online validation i.e. how can we configure the paypals?
16. What is meant by nl2br()?
nl2br — Inserts HTML line breaks before all newlines in a string string nl2br (string); Returns string with ” inserted before all newlines. For example: echo nl2br("god bless\n you") will output "god bless \n you" to your browser.

17. Draw the architecture of ZEND engine?
18. What are the current versions of apache, php, and mysql?
PHP: php5.1.2
MySQL: MySQL 5.1
Apache: Apache 2.1

19. What are the reasons for selecting lamp (Linux, apache, mysql, php) instead of combination of other software programs, servers and operating systems?
All of those are open source resource. Security of linux is very very more than windows. Apache is a better server that IIS both in functionality and security. Mysql is world most popular open source database. Php is more faster that asp or any other scripting language.

20. How can we encrypt and decrypt a data present in a mysql table using mysql?
AES_ENCRYPT () and AES_DECRYPT ()

21. How can we encrypt the username and password using php?
You can encrypt a password with the following Mysql>SET PASSWORD=PASSWORD("Password");
We can encode data using base64_encode($string) and can decode using base64_decode($string);

22. How many ways I can redirect a php page?
Here are the possible ways of php page redirection.
Using Java script:
'; echo 'window.location.href="'.$filename.'";'; echo ''; echo ''; echo ''; echo ''; } } redirect('http://maosjb.com'); ?>
Using php function:
Header("Location:http://maosjb.com ");

23. List out different arguments in php header function?
void header ( string string [, bool replace [, int http_response_code]])

24. What type of headers have to add in the mail function in which file a attached?
$boundary = '—–=' . md5( uniqid ( rand() ) );
$headers = "From: \"Me\"\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"";

25. What are the differences between public, private, protected, static, transient, final and volatile?
element Class Interface
Data field Method Constructor
modifier top level nested top level nested
(outer) (inner) (outer) (inner)
final yes yes no yes yes no no
private yes yes yes no yes no yes
protected yes yes yes no yes no yes
public yes yes yes yes yes yes yes
static yes yes no no yes no yes
transient yes no no no no no no
volatile yes no no no no no no

26. What are the different types of errors in php?
Three are three types of errors:
1. Notices: These are trivial, non-critical errors that PHP encounters while executing a script - for example, accessing a variable that has not yet been defined. By default, such errors are not displayed to the user at all - although, as you will see, you can change this default behaviour.

2. Warnings: These are more serious errors - for example, attempting to include() a file which does not exist. By default, these errors are displayed to the user, but they do not result in script termination.

3. Fatal errors: These are critical errors - for example, instantiating an object of a non-existent class, or calling a non-existent function. These errors cause the immediate termination of the script, and PHP's default behaviour is to display them to the user when they take place.

27. What is the functionality of the function strstr and stristr?
strstr() returns part of a given string from the first occurrence of a given substring to the end of the string. For example: strstr("user@example.com","@") will return "@example.com".
stristr() is idential to strstr() except that it is case insensitive.

28. What are the differences between PHP 3 and PHP 4 and PHP 5?
Go read the release notes at http://php.net.

29. How can we convert asp pages to php pages?
You can download asp2php front-end application from the site http://asp2php.naken.cc.

30. What is the functionality of the function htmlentities? Answer: htmlentities — Convert all applicable characters to HTML entities
This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities.

31. How can we get second of the current time using date function?
$second = date("s");

32. How can we convert the time zones using php?
33. What is meant by urlencode and urldocode?
urlencode() returns the URL encoded version of the given string. URL coding converts special characters into % signs followed by two hex digits. For example: urlencode("10.00%") will return "10%2E00%25?. URL encoded strings are safe to be used as part of URLs.
urldecode() returns the URL decoded version of the given string.

34. What is the difference between the functions unlink and unset?
unlink() deletes the given file from the file system.
unset() makes a variable undefined.

35. How can we register the variables into a session?
We can use the session_register ($ur_session_var) function.

36. How can we get the properties (size, type, width, height) of an image using php image functions?
To know the Image type use exif_imagetype () function
To know the Image size use getimagesize () function
To know the image width use imagesx () function
To know the image height use imagesy() function

37. How can we get the browser properties using php?
38. What is the maximum size of a file that can be uploaded using php and how can we change this?
You can change maximum size of a file set upload_max_filesize variable in php.ini file

39. How can we increase the execution time of a php script?
Set max_execution_time variable in php.ini file to your desired time in second.

40. How can we take a backup of a mysql table and how can we restore it.?
Answer: Create a full backup of your database: shell> mysqldump –tab=/path/to/some/dir –opt db_name Or: shell> mysqlhotcopy db_name /path/to/some/dir
The full backup file is just a set of SQL statements, so restoring it is very easy:

shell> mysql "."Executed";
mysql_close($link2);

53. List out the predefined classes in php?
Directory
stdClass
__PHP_Incomplete_Class
exception
php_user_filter

54. How can I make a script that can be bilanguage (supports Eglish, German)?
You can change charset variable in above line in the script to support bilanguage.

Read More

PHP Tutorial > String Functions

PHP string functions are used to manipulate string data. The most common string functions include the following :-


addcslashes — >Quote string with slashes in a C style
addslashes — >Quote string with slashes
bin2hex — >Convert binary data into hexadecimal representation
chop — >Alias of rtrim
chr — >Return a specific character
chunk_split — >Split a string into smaller chunks
convert_cyr_string — >Convert from one Cyrillic character set to another
convert_uudecode — >Decode a uuencoded string
convert_uuencode — >Uuencode a string
count_chars — >Return information about characters used in a string
crc32 — >Calculates the crc32 polynomial of a string
crypt — >One-way string hashing
echo — >Output one or more strings
explode — >Split a string by string
fprintf — >Write a formatted string to a stream
get_html_translation_table — >Returns the translation table used by htmlspecialchars and htmlentities
hebrev — >Convert logical Hebrew text to visual text
hebrevc — >Convert logical Hebrew text to visual text with newline conversion
html_entity_decode — >Convert all HTML entities to their applicable characters
htmlentities — >Convert all applicable characters to HTML entities
htmlspecialchars_decode — >Convert special HTML entities back to characters
htmlspecialchars — >Convert special characters to HTML entities
implode — >Join array elements with a string
join — >Alias of implode
lcfirst — >Make a string's first character lowercase
levenshtein — >Calculate Levenshtein distance between two strings
localeconv — >Get numeric formatting information
ltrim — >Strip whitespace (or other characters) from the beginning of a string
md5_file — >Calculates the md5 hash of a given file
md5 — >Calculate the md5 hash of a string
metaphone — >Calculate the metaphone key of a string
money_format — >Formats a number as a currency string
nl_langinfo — >Query language and locale information
nl2br — >Inserts HTML line breaks before all newlines in a string
number_format — >Format a number with grouped thousands
ord — >Return ASCII value of character
parse_str — >Parses the string into variables
print — >Output a string
printf — >Output a formatted string
quoted_printable_decode — >Convert a quoted-printable string to an 8 bit string
quoted_printable_encode — >Convert a 8 bit string to a quoted-printable string
quotemeta — >Quote meta characters
rtrim — >Strip whitespace (or other characters) from the end of a string
setlocale — >Set locale information
sha1_file — >Calculate the sha1 hash of a file
sha1 — >Calculate the sha1 hash of a string
similar_text — >Calculate the similarity between two strings
soundex — >Calculate the soundex key of a string
sprintf — >Return a formatted string
sscanf — >Parses input from a string according to a format
str_getcsv — >Parse a CSV string into an array
str_ireplace — >Case-insensitive version of str_replace.
str_pad — >Pad a string to a certain length with another string
str_repeat — >Repeat a string
str_replace — >Replace all occurrences of the search string with the replacement string
str_rot13 — >Perform the rot13 transform on a string
str_shuffle — >Randomly shuffles a string
str_split — >Convert a string to an array
str_word_count — >Return information about words used in a string
strcasecmp — >Binary safe case-insensitive string comparison
strchr — >Alias of strstr
strcmp — >Binary safe string comparison
strcoll — >Locale based string comparison
strcspn — >Find length of initial segment not matching mask
strip_tags — >Strip HTML and PHP tags from a string
stripcslashes — >Un-quote string quoted with addcslashes
stripos — >Find position of first occurrence of a case-insensitive string
stripslashes — >Un-quotes a quoted string
stristr — >Case-insensitive strstr
strlen — >Get string length
strnatcasecmp — >Case insensitive string comparisons using a "natural order" algorithm
strnatcmp — >String comparisons using a "natural order" algorithm
strncasecmp — >Binary safe case-insensitive string comparison of the first n characters
strncmp — >Binary safe string comparison of the first n characters
strpbrk — >Search a string for any of a set of characters
strpos — >Find position of first occurrence of a string
strrchr — >Find the last occurrence of a character in a string
strrev — >Reverse a string
strripos — >Find position of last occurrence of a case-insensitive string in a string
strrpos — >Find position of last occurrence of a char in a string
strspn — >Finds the length of the first segment of a string consisting entirely of characters contained within a given mask.
strstr — >Find first occurrence of a string
strtok — >Tokenize string
strtolower — >Make a string lowercase
strtoupper — >Make a string uppercase
strtr — >Translate certain characters
substr_compare — >Binary safe comparison of two strings from an offset, up to length characters
substr_count — >Count the number of substring occurrences
substr_replace — >Replace text within a portion of a string
substr — >Return part of a string
trim — >Strip whitespace (or other characters) from the beginning and end of a string
ucfirst — >Make a string's first character uppercase
ucwords — >Uppercase the first character of each word in a string
vfprintf — >Write a formatted string to a stream
vprintf — >Output a formatted string
vsprintf — >Return a formatted string
wordwrap — >Wraps a string to a given number of characters

Read More