63
CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2 www.ramkumarsjava.com

CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

Embed Size (px)

Citation preview

Page 1: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE

Grp2

Page 2: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

CODING STANDARDS

Page 3: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

1) According to ORACLE, 80% of the lifetime cost of a software goes to ? A. NEW SOFTWARE DEVELOPMENT B. MAINTENANCE

Ans: MAINTENANCE

Page 4: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

2) Which of the following describes the Importance of coding Conventions?? A. Improved code quality B. bug free code C. easy maintainability D. scalability, readability

Ans : all the above, therefore results in better performance

Page 5: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

3) According to coding convention,” package declaration” is the last statement in a program? A. TRUE B.FALSE

Ans : false, package is first statement in a program

Page 6: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

4)_______ is the template which describes the details of an OBJECT. A. VARIABLE B.CLASS C.METHOD D.PACKAGE

Ans: CLASS

Page 7: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

5) Which of the following class name , follows the code convention?? A. class customercontroller B. class Customercontroller C. class CustomerController D. all the above

Ans : (c)class CustomerControllerFirst letter of class name and internal names should be CAPITAL

Page 8: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

6) Which of the following is available type of COMMENTS?? A. Single line comments B. Block comments C. JavaDoc comments

ANS: ALL THE ABOVE

Page 9: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

7) _________ are the memory locations which keeps on changing their value throughout execution of the program A. Constants B. Variables C. Constructors D .none

ANS: variables

Page 10: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

8) _______ are the special variables whose value never change throughout the program.A. Constants B. VariablesC. ConstructorsD. None

Ans: Constants

Page 11: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

9) _______ are the code of blocks which are executed the moment object is created.A. ConstantsB. VariablesC. ConstructorsD. None

Ans: Constructors

Page 12: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

10) Which of the following , follows the code conventions of constants?A. static final int Max_Length = 80;B. static final int Max_length = 80;C. static final int MAX_LENGTH=80;D. NONE

Ans: (c), variable name should be in capital

Page 13: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

11) Code conventions that to be followed with METHODS?A. First letter should be in lower caseB. First letter of each internal word should be capitalC. Method name should represent functionality of it.D. All the above

Ans: All the above

Page 14: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

12) Every switch statement should include a default case.A. TrueB. False

Ans: True

Page 15: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

13)When an expression will not fit on a single line, break it according to those general principles, this is called as ________??

Ans: Wrapping Lines

Page 16: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

14) Statement 1: Camel case notations used for variable declarations. Statement 2: Pascal case notations are used for object names.A. 1 & 2 are trueB. 1 true, 2 falseC. 1 false, 2 trueD. 1&2 are false

Ans: B

Page 17: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

15) Hungarian notation is used in ???A. JavaB. CC.C++D. All the above

Ans :C

Page 18: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

16) Which tools helps in checking the coding standards of java program in eclipse?A. PMDB. Check styleC. ACQT D. ALL THE ABOVE

Ans: A, B

Page 19: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

17) Some of the Code Formatting conventions on SPACING:Can we use spaces between a function name and parenthesis?

Page 20: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

Can we use a single space after a comma between function arguments??

Page 21: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

Can we use spaces inside brackets??

Page 22: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

Can we use single space before and after comparison??

Page 23: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

UNIT TESTING

Page 24: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

1.In OOPs , the smallest unit is a _____

Ans: Class

Page 25: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

2.Unit may be called as ____

Ans: Component

Page 26: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

3.The smallest testable part of an application is ____

Ans: Unit

Page 27: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

4. Unit testing validates the source code of a defined _____

Ans:Functional unit

Page 28: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

5.Unit testing helps a software developer to:(a)test code for correctness(b)Re-factor code faster(c)design better(d)Enhance documentation(e)All of the above

Answer: e

Page 29: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

6. Unit testing is usually done by the tester ,during the build phase of the application.(True/False)

Ans: False

Page 30: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

7._______ is the first step in build phase

Ans: UNIT TEST SCRIPTS or UNIT TEST CASES(UTC)

Page 31: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

8.Unit test should cover

Ans: -code -branches -paths -cycles

Page 32: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

9.Which technique is used for unit testing?

(a)Black-box testing(b)White-box testing(c)Both(d)None

Ans: b

Page 33: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

10.Which tool is used for unit testing?

Ans: JUNIT

Page 34: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

11.Benefits of unit testing are:-(a)facilitates change(b)simplifies integration(c)Provides living documentation(d)serves as a design(e)All of the above

Ans: e

Page 35: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

12.Unit testing deliverables are?

Ans:-Test Condition and Expected Results(TCER)-Test Cycle Control Sheet(TCCS)-Test Data-Test Drivers/Media Program Document-Test Environment Document

Page 36: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

13.Unit testing exposes only the presence of errors, not their absence.(True/False)

Ans: True

Page 37: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

14.A ____ is a statement that defines a constraint that must be satisfied by the program being tested

Ans: Test condition

Page 38: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

15.Test condition general principles are?

Ans:-Branch coverage-Condition coverage-Loop coverage-Interface coverage-Logic path coverage

Page 39: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

16.____ , _____ & _______ belong to loop coverage Ans: FOR, WHILE, DO-WHILE

Page 40: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

17.The ______ is when all the test conditions are re-executed for function modules influenced by a change or bug fix to the program

Ans: Regression test

Page 41: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

18. For database operations which three cases should be tested in a unit test?

Ans: 1) WHERE clause 2) data definition & operation 3) stored procedure & function

Page 42: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

19.The ______ is when all the test conditions are re-executed for function modules influenced by a change or bug fix to the program

Ans: Regression test

Page 43: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

20.The ____ checks the performance capability of the software or a system

Ans: Performance test

Page 44: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

21.During regression test the test data is the same as the before.(True/False)

Ans: True

Page 45: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

22.The nature of unit testing may have similarities with the debugging, and both can be considered same.(True/false)

Ans: False

Page 46: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

ASSEMBLY TESTING

Page 47: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

Q1) state true/false

Assembly test does not test complex functionality of final product.

Ans: true

Page 48: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

Q2) TCER stands for

A. Test condition and elaborated requirementsB. Test condition and expected requirementC. Test condition and expected resultD. Test condition and elaborated requests

Ans: c

Page 49: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

Q3) TCER A. Defines when and by whom test cycles are executedB. Explains what to test and how to carry out the test at high levelC. Details the exact stepsD. Explains the objectives and scope of the test.

Ans: B

Page 50: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

Q4) defines when and by whom test cycles are executed.

A. TCERB. TCCSC. RTMD. TEST SCRIPT

Ans: B

Page 51: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

Q5) test scenarios are created by:

A. Technical leadB. ManagerC. DeveloperD. Testing team

Ans: A

Page 52: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

Q6) ______________ and ______________ forms the part of test plan to be executed by test execution team.

A. TCER AND TCCSB. TCCS AND TEST SCRIPTC. TCCS AND TEST SCENARIOSD. TCER AND TEST SCRIPT

ANS: B

Page 53: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

Q7) _____________ is used as an input into planning the test to ensure that the application under testing meets the clients requirements.

A. Requirement documentB. Functional specification documentC. Technical specification documentD. RTM

Ans:A

Page 54: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

Q8)test condition are designed to address which of the following. Select all that apply.

A. Limit valuesB. Negative conditionsC. Exception conditionD. Positive condition

Ans: All

Page 55: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

PERFORMANCE

Page 56: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

1.Identify the reasons for performance degrade

(a)Lot of repeated method calls(b)lot of heavy weight object creation(c)improper use of loop(d)IO bottleneck(e)Switch(long if/else if) statements not used judiciously(f)Logging not used judiciously(g)Exception Handling not done properly

(i)(a),(b),(d) & (g) (ii)(b),(c),(f) & (g)(iii)all of the above(iv))c),(d),(e) & (g)

Ans: (iii)

Page 57: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

2.Performance improvement techniques in object creation?

(a)avoid creating objects in a loop(b)always try to use String literals instead of String objects(c)never create objects just for accessing a method(d)whenever you are done with an object make the reference null (e)never keep inheriting chains long(f)use primitive data types rather than using wrapper classes(g)whenever possible avoid using class variables, use local variables instead

(i)All of the above(ii)All except (e)(iii)All except (g)(iv)None of the above

Ans: (i)

Page 58: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

3. Lazy object creation refers to ________

Ans: delaying the memory allocation to an object till it is not being put into use

Page 59: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

4. Performance improvement techniques in using loops?

(a)use INT data type as loop index variable(b)avoid method calls, assigning values to variables or testing for conditions(c)avoid accessing array elements in a loop(d)avoid using try-catch inside the loops(e)if possible convert nested loops to a single loop

(i)(a),(b),(d) & (e) (ii)All of the above(iii)I’m not sure!

Ans: (ii)

Page 60: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

5. Performance improvement technique for IO

Ans: Use Buffered Streams to buffer the data and then read/write which gives good performance

Page 61: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

6. Choose the correct option: we’ll get bad performance if we use?

(a)FileInputStream.read(byte[] b)(b)FileOutputStream.write(int b)(c)BufferedInputStream.read()(d)BufferedOutputStream.write(int b)

(i)(a)(ii)(a) & (b)(iii)(c)(iv)(c) & (d)

Ans: (ii)

Page 62: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

7. Performance improvement techniques in Exception Handling?

(a)In a catch block avoid using the generic class Exception(b)Whenever you are using ‘throws’ clause always use the specific subclass of Exception(c)Don’t use Exception handling for anything other than exception handling like to control the flow of your program(d)Always use finally block to release resources(e)Don’t use Exception handling in loops(f)When using method calls always handle the exceptions in the method where they occur, don’t allow them to propagate to the calling method unless it is specifically required

(i)All except (f)(ii)All except (b)(iii)All of the above(iv)None of the aboveAns: (iii)

Page 63: CODING STANDARDS,TESTING(UNIT & ASSEMBLY) &PERFORMANCE Grp2

www.ramkumarsjava.com

8. Multithreading technique improves application performance.T/F?

Ans: T